Event

interface Event

Events are how PolyUI communicates between components and to the user.

Everything from mouse clicks, key presses, text input changes, initialization and destruction of components are communicated through events.

(since 1.3.1) events can be destructured, like so:

component.onClick { (x, y) ->
// access and use the x and y position of the mouse with a prettier syntax
}

These events can be dispatched by your own components, and you can add your own events - though PolyUI comes with 22 events by default.

event specificity

Some events are specific, requiring constructor parameters to ensure that for example, only single, left-click events are handled by any given handler. others are non-specific, like Focused.UnmappedInput and receive any matching event of the type.

by default, an event is non-specific. in order to make it specific, override the equals and hashCode methods.

Inheritors

Types

Link copied to clipboard
abstract class Change : Event

Events related to specific things that occur in some components, for example when a switch is toggled, a slider is moved or a text is changed.

Link copied to clipboard
interface Focused : Event

Events for focusable components (components which receive keyboard input)

Link copied to clipboard
interface Lifetime : Event

Events related to the lifetime of a component.

Link copied to clipboard
interface Mouse : Event

Events related to the mouse.