mouseMotionListener

Runs onMouseMove whenever the pointer moves over the component, whether or not a button is held.

onMouseMove is read when the event fires, so writing a fresh lambda on every recomposition registers nothing again.

Return

this chain with the mouse motion callback declared on it.

Parameters

onMouseMove

receives the event, whose x and y are in the component's own coordinates and can fall outside it while a drag that began here continues.

See also


fun SwingModifier.mouseMotionListener(onMouseDragged: (MouseEvent) -> Unit = UNDECLARED, onMouseMoved: (MouseEvent) -> Unit = UNDECLARED): SwingModifier

Runs onMouseDragged while the pointer moves with a button held, and onMouseMoved while it moves with none. A movement left undeclared reports nowhere.

Each lambda is read when its event fires, so writing a fresh one on every recomposition registers nothing again.

Declaring none at all is refused.

Return

this chain with the mouse motion callbacks declared on it.

Parameters

onMouseDragged

keeps reporting after the pointer leaves the component, until the button is released.

onMouseMoved

stops as soon as the pointer leaves.

See also


Attaches a MouseMotionListener (addMouseMotionListener/removeMouseMotionListener).

Return

this chain with the mouse motion listener declared on it.

Parameters

listener

attached by identity, so a remembered instance stays put while a fresh one on every pass is detached and re-added.

See also