onExportDone

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.

Declaring onExportDone alone, with neither a draggable nor a clipboard source on the same component, has nothing of its own to export through this seam: the component's own copy and cut keep running unclaimed, and onExportDone is not invoked for them. A drag it starts is not claimed either, but is not left alone the way copy and cut are: the drag machinery re-reads the component's transfer handler once it recognizes the gesture, finds no declared transferable there, and completes as TransferHandler.NONE - a completion onExportDone does receive, even though no drag actually ran.

Requires a JComponent target. Composes with draggable and clipboard on the same component: the component's data-transfer modifiers configure one underlying transfer handler with a single export-completion seam, so the callback observes every export a declared source on this component produces, regardless of which modifier declared that source. onExportDone is read on each export, so passing a fresh value across recompositions takes effect immediately.

Return

this modifier with the export-completion callback declared on it.

Parameters

onExportDone

receives the exported data - null where the export produced none - and the TransferAction that completed, which is where a source implementing MOVE removes the data.

See also