Package-level declarations

Types

Link copied to clipboard
@Stable
class ClipboardHandle

A programmatic trigger for the clipboard copy/cut/paste of the component a clipboard modifier binds it to. Obtain one from rememberClipboardHandle, pass it to clipboard(handle = ...), then call copy/cut/paste from an event handler (e.g. a menu item) to drive the same operations the bound keystrokes do - without ever holding the underlying JComponent.

Functions

Link copied to clipboard
fun SwingModifier.clipboard(transferable: () -> Transferable?, onPaste: (transferable: Transferable) -> Boolean, canImport: (flavors: List<DataFlavor>) -> Boolean = { true }, bindKeys: Boolean = true, handle: ClipboardHandle? = null): SwingModifier

Enables system-clipboard copy/cut export and paste import on the component, over the same transfer handler draggable and dropTarget use.

Link copied to clipboard
fun SwingModifier.draggable(exportedActions: Int, transferable: () -> Transferable?): SwingModifier

Makes the component a drag SOURCE that exports a Transferable when dragged.

Link copied to clipboard
fun SwingModifier.dropTarget(acceptedActions: Int, onDrop: (transferable: Transferable) -> Boolean, canImport: (flavors: List<DataFlavor>) -> Boolean = { true }): SwingModifier

Makes the component a drop TARGET that imports a dropped Transferable.

Link copied to clipboard
fun SwingModifier.onExportDone(onExportDone: (data: Transferable?, action: Int) -> Unit): SwingModifier

Registers a callback told the outcome of every export a draggable or clipboard source declared on this component produces: once a drag ends or a clipboard copy/cut completes, onExportDone receives the exported data and the TransferAction that occurred - TransferHandler.COPY, TransferHandler.MOVE, or TransferHandler.NONE when nothing was transferred, in which case the data is whatever the export offered, or null where it produced none. A source offering MOVE implements move semantics here: on a reported MOVE it removes the moved data. With no callback registered a completed export removes nothing, like TransferHandler.exportDone itself.

Link copied to clipboard

Creates and remembers a ClipboardHandle to drive a component's clipboard copy/cut/paste programmatically. Pass it to clipboard(handle = ...) to bind it to that component, then call ClipboardHandle.copy/ClipboardHandle.cut/ClipboardHandle.paste from an event handler.