PlatformEvent

sealed class PlatformEvent(source)

An event taken from the platform's event queue by EventPump.pollOrNull.

The set of events is closed, so a when over them is exhaustive. The pump skips platform events that have no subclass here.

Mouse positions are in window points with (0, 0) at the top-left corner of the client area, the unit of Window.width; multiply by Window.pixelDensity for pixels.

Samples live in the sandbox because they need a display.

Inheritors

Types

Link copied to clipboard
class GamepadAxisMoved(val id: GamepadId, val axis: GamepadAxis, val value: Float) : PlatformEvent

Reports that axis on the gamepad id moved to value.

Link copied to clipboard

Reports that button was pressed on the gamepad id.

Link copied to clipboard

Reports that button was released on the gamepad id.

Link copied to clipboard
class GamepadConnected(val id: GamepadId, val name: String) : PlatformEvent

Reports that a gamepad named name was connected and is now known as id.

Link copied to clipboard

Reports that the gamepad id was disconnected. The id is not used again.

Link copied to clipboard
class KeyDown(val key: KeyCode, val isRepeat: Boolean, val scancode: Scancode) : PlatformEvent

Reports that a key was pressed: key is its label under the current layout and scancode its physical position. isRepeat is true when the key is being held down and the event comes from key repeat rather than a new press.

Link copied to clipboard
class KeyUp(val key: KeyCode, val scancode: Scancode) : PlatformEvent

Reports that a key was released: key is its label under the current layout and scancode its physical position.

Link copied to clipboard
class MouseButtonDown(val button: MouseButton, val x: Float, val y: Float, val clicks: Int) : PlatformEvent

Reports that button was pressed with the mouse at (x, y) in window points.

Link copied to clipboard
class MouseButtonUp(val button: MouseButton, val x: Float, val y: Float) : PlatformEvent

Reports that button was released with the mouse at (x, y) in window points. Buttons past MouseButton.X2 are not reported.

Link copied to clipboard
class MouseMoved(val x: Float, val y: Float, val dx: Float, val dy: Float) : PlatformEvent

Reports that the mouse moved to (x, y) in window points, by dx and dy points since the previous MouseMoved.

Link copied to clipboard
class MouseWheelScrolled(val dx: Float, val dy: Float) : PlatformEvent

Reports that the mouse wheel or a touchpad scrolled by dx and dy.

Link copied to clipboard

Asks the application to quit, for example because the user closed the last window.

Link copied to clipboard
class WindowDensityChanged(val pixelDensity: Float) : PlatformEvent

Reports that a window's display scale changed, typically because it moved to a display with a different pixel density. pixelDensity is the window's Window.pixelDensity now.

Link copied to clipboard

Reports that a window gained keyboard focus, so key events go to it.

Link copied to clipboard

Reports that a window lost keyboard focus, so key events stop going to it.

Link copied to clipboard
class WindowResized(val pixelWidth: Int, val pixelHeight: Int) : PlatformEvent

Reports that a window's drawable size changed to pixelWidth by pixelHeight pixels.