T
- the type of the drop target component@JavaScript(value="frontend://dndConnector.js") @JsModule(value="./dndConnector-es6.js") public interface DropTarget<T extends Component> extends HasElement
This can be used by either implementing this interface with the static API
create(Component)
, configure(Component)
or
configure(Component, boolean)
.
DragSource
Modifier and Type | Method and Description |
---|---|
default Registration |
addDropListener(ComponentEventListener<DropEvent<T>> listener)
Attaches drop listener for the component this maps to.
|
static <T extends Component> |
configure(T component)
Gives access to the generic drop target API for the given component.
|
static <T extends Component> |
configure(T component,
boolean active)
Gives access to the generic drop target API for the given component and
either activates or deactivates the drop target.
|
static <T extends Component> |
create(T component)
Makes the given component a drop target and gives access to the generic
drop target API for the component.
|
default DropEffect |
getDropEffect()
Returns the drop effect for the current drop target.
|
default T |
getDropTargetComponent()
Returns the drop target component.
|
default Element |
getElement()
Returns the element which is made as a drop target in the UI.
|
default boolean |
isActive()
Gets whether this drop target is activate or not.
|
default void |
setActive(boolean active)
Activate or deactivate this drop target.
|
default void |
setDropEffect(DropEffect dropEffect)
Sets the drop effect for the current drop target.
|
static <T extends Component> DropTarget<T> create(T component)
The given component will be always set an active drop target, if this is
not desired, use either method configure(Component, boolean)
or
setActive(boolean)
.
T
- the type of the componentcomponent
- the component to make a drop targetconfigure(Component)
,
configure(Component, boolean)
static <T extends Component> DropTarget<T> configure(T component)
Unlike create(Component)
and
configure(Component, boolean)
, this method does not change the
active drop target status of the given component.
T
- the type of the componentcomponent
- the component to make a drop targetconfigure(Component, boolean)
,
create(Component)
static <T extends Component> DropTarget<T> configure(T component, boolean active)
This method is a shorthand for calling configure(Component)
and
setActive(boolean)
.
The drop target active state can be changed at any time with
setActive(boolean)
.
T
- the type of the componentcomponent
- the component to provide drop target API foractive
- true
to set the component as an active drop target,
false
for notcreate(Component)
,
configure(Component)
default T getDropTargetComponent()
The default implementation of this method returns this
. This
method exists for type safe access for the drop target component and
being able to provide access to drop target API for any component.
default Element getElement()
getDropTargetComponent()
.getElement
in interface HasElement
default void setActive(boolean active)
active
- true
to allow drops, false
to notdefault boolean isActive()
true
to allow drops, false
to notdefault void setDropEffect(DropEffect dropEffect)
dragenter
, dragover
and drop
events
and needs to match the effectAllowed
property for the drag
operation.
NOTE: If the drop effect that doesn't match the effectAllowed of the drag source, it DOES NOT prevent drop on IE11 and Safari! For FireFox and Chrome the drop is prevented if the properties don't match.
dropEffect
- the drop effect to be set or null
to not modifydefault DropEffect getDropEffect()
null
if none setsetDropEffect(DropEffect)
default Registration addDropListener(ComponentEventListener<DropEvent<T>> listener)
setDropEffect(DropEffect)
matches a one
set for the drag operation (see
DragSource.setEffectAllowed(EffectAllowed)
).
NOTE: the drop listener might be triggered for a drop inside
another drop target that is inside this drop target component! For this,
the setActive(boolean)
does not have effect.
listener
- Listener to handle drop event.Copyright © 2023. All rights reserved.