Skip to main content

Drop (8.5)

Enables receiving per drag and drop.

modifier Drop

Example

import { Frame, Rectangle, Overlay, Drop, Text } from ui

export component Main {

text: String = "Waiting..."

Rectangle(color: Color(0xFF80C0D0), radius: 4) with {
Frame(height: 128)
Overlay {
Text(self.text)
}

Drop(
of: ["text/plain"],
perform: fun (event, action) {
self.text = "\{action}: \{event.data(format: "text/plain")}"
return true
},
)
}
}

export var main = Main()

Constructors

With Predicate

constructor(can_accept: (DropEvent) -> (Bool), enter: (DropEvent) -> (), update: (DropEvent) -> (DropAction?), exit: () -> (), perform: (DropEvent, DropAction) -> (Bool))
can_accept: (DropEvent) -> (Bool)

Called when a drag enters or moves within the drop area to determine whether or not it is acceptable.

See DropEvent.

enter: (DropEvent) -> ()

Called when a drag enters the drop area.

This parameter is optional and can be omitted if you do not need to perform any action when a drag enters the drop area.

See DropEvent.

update: (DropEvent) -> (DropAction?)

Called when a drag moves within the drop area, allowing you to update the action that will be performed on drop. If the function returns nil then the proposed action is used.

This parameter is optional and can be omitted if you do not need to update the action.

See DropEvent.

exit: () -> ()

Called when a drag exits the drop area.

This parameter is optional and can be omitted if you do not need to perform any action when a drag exits the drop area.

perform: (DropEvent, DropAction) -> (Bool)

Called when a valid drop occured.

The DropAction parameter indicates the action that was performed by the target, e.g. DropAction.copy, DropAction.link or DropAction.move.

See DropEvent, DropAction.


By MIME Type

constructor(of: [String] = [], enter: (DropEvent) -> (), update: (DropEvent) -> (DropAction?), exit: () -> (), perform: (DropEvent, DropAction) -> (Bool))
of: [String] = []

A list of MIME types that this drop area accepts.

enter: (DropEvent) -> ()

Called when a drag enters the drop area.

This parameter is optional and can be omitted if you do not need to perform any action when a drag enters the drop area.

See DropEvent.

update: (DropEvent) -> (DropAction?)

Called when a drag moves within the drop area, allowing you to update the action that will be performed on drop. If the function returns nil then the proposed action is used.

This parameter is optional and can be omitted if you do not need to update the action.

See DropEvent.

exit: () -> ()

Called when a drag exits the drop area.

This parameter is optional and can be omitted if you do not need to perform any action when a drag exits the drop area.

perform: (DropEvent, DropAction) -> (Bool)

Called when a valid drop occured.

The DropAction parameter indicates the action that was performed by the target, e.g. DropAction.copy, DropAction.link or DropAction.move.

See DropEvent.

See DropAction.

Layout Behavior

None.