Drop Experimental
Enables receiving per drag and drop.
modifier Drop
import { Drop, Text } from ui
export var main = Text("Drop Something") with {
Drop(fun (event: DropEvent) {
print("something got dropped")
})
}
Constructors
(_ action)
Enables receiving data per drag & drop. In this simple version no validation is done and every drop is valid.
_ action: (DropEvent) -> ()
Called when something got dropped.
See DropEvent.
(of:action:acceptable:position)
Enables receiving data per drag & drop matching a list of accepted MIME types.
of: [String]
An array of accepted MIME types.
See this article for more information on MIME types.
action: (DropEvent) -> ()
Called when a valid drop occured. This means the event contains data for at least one of the acceptable MIME types.
See DropEvent.
acceptable: $<Bool?> (optional)
Allows observing whether an acceptable drag is within the drop area.
If the value is nil
then no drop is within the area.
position: $<Point?> (optional)
Allows observing the drag position in the drop area.
If the value is nil
then no drop is within the area.
See Point
(accepted:action:acceptable:position)
Enables receiving data per drag & drop with a custom acceptance function.
accepted: (DropEvent) -> (Bool)
Called when a drag enters or moves within the drop area to determine whether or not it is acceptable.
The result of this function determines what the acceptable
binding reports and whether action
is called on drop.
action: (DropEvent) -> ()
Called when a valid drop occured. This means the event contains data for at least one of the acceptable MIME types.
See DropEvent.
acceptable: $<Bool?> (optional)
Allows observing whether an acceptable drag is within the drop area.
If the value is nil
then no drop is within the area.
position: $<Point?> (optional)
Allows observing the drag position in the drop area.
If the value is nil
then no drop is within the area.
See Point
Layout Behavior
None.
DropEvent
class DropEvent
Methods
data(_ mime_type: String) -> (String)
Retrieves the data for the given MIME type.
Returns an empty
String
if no such data exists.
See this article for more information on MIME types.
has_format(_ mime_type: String) -> (Bool)
Returns whether data for the given MIME type was attached to the drag event.