-
Notifications
You must be signed in to change notification settings - Fork 1
Widget Callbacks
github-actions[bot] edited this page Apr 3, 2026
·
1 revision
Two ways to register a callback:
-
Method override - define the bare method on a subclass. Called by the framework as part of internal widget behaviour. This is for stuff like a blinking cursor on a
TextInputor normal drawing code for this type of widget. -
Registration wrapper - call
widget:onSomething(fn)to append a user-defined handler. Multiple handlers can be registered. Use this for stuff like defining what happens when you press a specificButton.
-
type- event name -
timestamp- creation time -
target- original widget target -
currentTarget- widget currently handling this phase -
consumed- whether a handler consumed the event -
stopsPropagation- whether propagation is stopped -
consume()- marks consumed and stops propagation
-
x/y- screen coordinates -
localX/localY- coordinates relative totarget -
button- mouse button index -
dx/dy- optional movement or wheel delta -
isTouch- whether source input is touch
-
key- logical key name -
scancode- physical key identifier -
isRepeat- whether this is a repeated key press -
modifiers.shift/ctrl/alt- modifier-key state -
value- optional text/value payload (if present)
-
text- entered printable text -
modifiers.shift/ctrl/alt- modifier-key state
-
target/currentTarget- focus target
See: Lifecycle.
-
mousePressed(MouseEvent)/onMousePressed(fn) -
mouseReleased(MouseEvent)/onMouseReleased(fn) -
mouseMoved(MouseEvent)/onMouseMoved(fn) -
mouseEntered(MouseEvent)/onMouseEntered(fn)/onHover(fn) -
mouseExited(MouseEvent)/onMouseExited(fn) -
mouseWheel(MouseEvent)/onMouseWheel(fn) -
clicked(MouseEvent)/onClick(fn)
-
keyPressed(KeyboardEvent)/onKeyPressed(fn) -
keyReleased(KeyboardEvent)/onKeyReleased(fn) -
textInput(TextInputEvent)/onTextInput(fn)
-
focusGained(FocusEvent)/onFocusGained(fn) -
focusLost(FocusEvent)/onFocusLost(fn)
Registration wrappers append to __handlers; property assignment (widget.dragStart = fn) sets a single overrideable callback. Both fire.
-
dragStart(MouseEvent)/onDragStart(fn) -
drag(MouseEvent, deltaX, deltaY)/onDrag(fn) -
dragEnd(MouseEvent)/onDragEnd(fn)
Registration wrappers append to __handlers. Property assignment (widget.dragOver = fn) sets a single overrideable callback.
-
dragOver(MouseEvent, draggedWidget)/onDragOver(fn) -
dragLeave(MouseEvent, draggedWidget)/onDragLeave(fn) -
drop(MouseEvent, draggedWidget)/onDrop(fn)