Skip to main content

EventPayload

Enum EventPayload 

Source
pub enum EventPayload<'a> {
Show 50 variants Clicked, TextChanged(&'a str), TextSubmitted(&'a str), FocusLost, ProtocolError { code: u32, message: &'a str, }, KeyDown { key: Key, shift_key: bool, ctrl_key: bool, alt_key: bool, meta_key: bool, repeat: bool, code: u32, text: &'a str, }, RangeRequested { start: u32, count: u32, }, ValueChanged(f64), WindowSizeChanged { width_dp: f32, height_dp: f32, class: WindowSizeClass, height_class: WindowHeightClass, safe_area_top: f32, safe_area_leading: f32, safe_area_trailing: f32, }, FilesEntered, FilesDropped(&'a str), DesignSystemResolved(DesignSystem), Resync, LifecycleStart, LifecycleStop, NotificationActivated { action: u32, key: &'a str, }, NotificationPermissionChanged(NotificationPermission), CodeChanged { version: u32, start_line: u32, start_column: u32, end_line: u32, end_column: u32, text: &'a str, }, CodeEditRejected { request_id: u32, base_version: u32, current_version: u32, start_line: u32, start_column: u32, end_line: u32, end_column: u32, }, CodeHovered { decoration: u64, line: u32, column: u32, phase: HoverPhase, }, CodeSaveRequested { version: u32, }, DecorationActivated { decoration: u64, }, AnimationEvent { animation_id: u32, kind: AnimationEventKind, property: AnimatedProperty, slot: u8, iteration: u32, elapsed_ms: f32, time_nanos: u64, }, ReducedMotionChanged(ReducedMotion), Pointer {
Show 13 fields kind: PointerKind, pointer_id: u32, pointer_type: PointerType, x: f32, y: f32, buttons: u32, button: u32, modifiers: u32, click_count: u32, delta_x: f32, delta_y: f32, delta_mode: WheelDeltaMode, timestamp_nanos: u64,
}, ZoomChanged { k: f32, os: f32, level: i32, }, SelectionChanged { version: u32, anchor_line: u32, anchor_column: u32, active_line: u32, active_column: u32, }, VisibleRangeChanged { version: u32, first_line: u32, last_line: u32, }, EditorFocusChanged { focused: bool, }, FoldChanged { start_line: u32, collapsed: bool, }, CompositionChanged { composing: bool, }, WindowCloseRequested, WindowFocusChanged { focused: bool, }, WindowMoved { x: f32, y: f32, width: f32, height: f32, }, WindowDrag { phase: u32, screen_x: f32, screen_y: f32, over_window: u32, }, WindowDragOver { kind: u32, window: u32, x: f32, y: f32, }, WindowUnavailable, WindowClosed, WindowRequested { key: &'a str, request: u32, }, ApplicationReopen, FocusGained, KeyUp { key: Key, shift_key: bool, ctrl_key: bool, alt_key: bool, meta_key: bool, repeat: bool, code: u32, text: &'a str, }, CodeMetrics { line_height_px: f64, }, CodeScrolled { offset_px: f64, }, FileDialogResult { request: u32, status: FileDialogStatus, filter: u32, paths: &'a str, }, ClipboardText { request: u32, status: u32, len: u32, text: &'a str, }, IoAnswer { request: u32, status: IoStatus, data: &'a [u8], }, FileHandles { request: u32, status: FileDialogStatus, filter: u32, delivery: FileDelivery, first_handle: u32, names: &'a str, kinds: &'a str, }, StorageLocation(&'a str), ScrollChanged { item: u32, settled: bool, can_scroll_backward: bool, can_scroll_forward: bool, x_px: f64, y_px: f64, max_x_px: f64, max_y_px: f64, viewport_width_px: f64, viewport_height_px: f64, },
}

Variants§

§

Clicked

§

TextChanged(&'a str)

§

TextSubmitted(&'a str)

§

FocusLost

§

ProtocolError

Fields

§code: u32
§message: &'a str
§

KeyDown

Fields

§key: Key
§shift_key: bool
§ctrl_key: bool
§alt_key: bool
§meta_key: bool
§repeat: bool

True when the event comes from a held key repeating.

§code: u32

The physical key as a USB HID usage value, the same on every layout.

§text: &'a str

The DOM key string, such as "ArrowDown" or "a".

§

RangeRequested

The Renderer asks the Host to materialise the visible item range.

Fields

§start: u32
§count: u32
§

ValueChanged(f64)

A control’s new value, in the widget’s own unit: an epoch count for a picker, a position for a slider, 0.0 or 1.0 for a toggle. The Renderer decided how the user reached it, so nothing about calendars, wheels, tracks or thumbs crosses here.

One f64 holds all of them: integers up to 2^53 survive it exactly, so splitting the event in two would only give the same concept two names.

§

WindowSizeChanged

The window, or one observed node, moved into a different size class. The Renderer measures it and sends this only when a class changes, never on every layout pass. A node_id of 0 is the window; anything else is the node that asked to be measured.

Fields

§width_dp: f32
§height_dp: f32
§height_class: WindowHeightClass
§safe_area_top: f32
§safe_area_leading: f32
§safe_area_trailing: f32
§

FilesEntered

Files are over a node that said it would take them. Nothing about what they are: the platforms disagree about what is knowable before a drop, and a screen that only needs to light up does not need to know.

§

FilesDropped(&'a str)

Files were let go over a node. The paths arrive together, separated by a byte no path on any of the three desktops may contain.

§

DesignSystemResolved(DesignSystem)

The Renderer resolved the theme and this is what it chose. Sent once and then only when the answer changes, the same way a size class is.

§

Resync

The Renderer lost its node table and asks for the whole tree again. A recreated Activity is the case that produces it.

§

LifecycleStart

The platform brought the UI back. Timers and animations resume.

§

LifecycleStop

The platform stopped the UI. Timers and animations are suppressed, so a process that is not on screen is not asked to draw.

§

NotificationActivated

The user pressed a notification the application posted. action is 0 for the body and 1 or 2 for an action button; key is the name the application gave it.

A name rather than a handler, because a notification outlives the component that posted it by hours and a callback dies with its scope.

Fields

§action: u32
§key: &'a str
§

NotificationPermissionChanged(NotificationPermission)

Whether notifications may be shown, sent once after start and then only when the answer changes.

§

CodeChanged

One committed edit to a code editor’s document.

The range is in the document as it stood before the edit, and version is the version the edit produced. Lines and columns count from zero and columns are UTF-16 code units, which is what a language server counts in, so the event can be handed to one unchanged. Text still being composed by an input method never arrives here: only what the reader committed does.

Fields

§version: u32
§start_line: u32
§start_column: u32
§end_line: u32
§end_column: u32
§text: &'a str
§

CodeEditRejected

An edit the Host asked for and the Renderer did not apply, because the reader had changed the same place since the version the edit was written against.

Fields

§request_id: u32
§base_version: u32
§current_version: u32
§start_line: u32
§start_column: u32
§end_line: u32
§end_column: u32
§

CodeHovered

A pointer came to rest over a place in a code editor, or left it. decoration is the id of the hover anchor under it, or zero where there is none.

Fields

§decoration: u64
§line: u32
§column: u32
§

CodeSaveRequested

The reader pressed the platform’s save shortcut on a code editor.

Fields

§version: u32
§

DecorationActivated

A decoration was pressed or accepted, named by the id the application gave it.

Fields

§decoration: u64
§

AnimationEvent

Something happened to an animation the Renderer is playing, sent only for the kinds the animation asked for. It names the node the animation plays on and no handler.

Fields

§animation_id: u32
§slot: u8
§iteration: u32

The iteration the animation was in at that moment.

§elapsed_ms: f32

What CSS reports as elapsedTime: active time, without the delay, in ms.

§time_nanos: u64

The frame the moment happened in; for Ready, the start time it was given.

§

ReducedMotionChanged(ReducedMotion)

Whether the platform asks for reduced motion, sent once after start and then only when the answer changes.

§

Pointer

A pointer did something inside a node that subscribed to it. Coordinates are in dp from the node’s top left corner, buttons is what is held now and button is the one that caused a Down or an Up. timestamp_nanos is on the frame time’s clock.

Fields

§pointer_id: u32
§pointer_type: PointerType
§buttons: u32
§button: u32
§modifiers: u32
§click_count: u32
§delta_x: f32
§delta_y: f32
§delta_mode: WheelDeltaMode
§timestamp_nanos: u64
§

ZoomChanged

How large the Renderer is drawing: k = os × 1.2^level. Sent once at start and again whenever any of the three changes. A move to a screen of another density changes none of them and is not reported.

Fields

§os: f32
§level: i32
§

SelectionChanged

The selection of a code editor moved, or an edit moved it. version is the document version it is read against, the same series CodeChanged counts, and an edit’s change always arrives first. Columns are UTF-16 units and never fall between the two halves of a pair.

Fields

§version: u32
§anchor_line: u32
§anchor_column: u32
§active_line: u32
§active_column: u32
§

VisibleRangeChanged

The lines of a code editor that are on screen changed. Folded lines are skipped, so first_line and last_line are the first and last lines the reader can see.

Fields

§version: u32
§first_line: u32
§last_line: u32
§

EditorFocusChanged

A code editor gained or lost the keyboard focus.

Fields

§focused: bool
§

FoldChanged

The reader folded or unfolded the stretch that starts on start_line.

Fields

§start_line: u32
§collapsed: bool
§

CompositionChanged

An input method started or ended a composition in a code editor. What is being composed stays in the Renderer: only the fact crosses.

Fields

§composing: bool
§

WindowCloseRequested

The user asked to close a window. The window stays until the application removes its Window node. Delivered to the node.

§

WindowFocusChanged

A window became the key window or stopped being it.

Fields

§focused: bool
§

WindowMoved

A window’s outer frame moved or changed size, in screen dp. At most once a frame.

Fields

§width: f32
§height: f32
§

WindowDrag

A torn-off window being dragged. phase is 1 for a move, 2 for the end and 3 for a cancel; over_window is the node id of the window under the pointer, or 0.

Fields

§phase: u32
§screen_x: f32
§screen_y: f32
§over_window: u32
§

WindowDragOver

A dragged window passing over a node that has OnWindowDragOver. kind is 1 for enter, 2 for move, 3 for leave and 4 for drop, window is the dragged window’s node id, and the position is inside the node, in dp.

Fields

§kind: u32
§window: u32
§

WindowUnavailable

A window that could not be opened here: the platform has no second window, or it refused. Delivered once, to the node.

§

WindowClosed

The platform closed a window without asking. The window is already gone.

§

WindowRequested

A window the application has no node for yet, with the RestoreKey it was made under (empty for a new one) and a request number. Delivered to the root.

Fields

§key: &'a str
§request: u32
§

ApplicationReopen

The user opened the application again while it had no window. Delivered to the root.

§

FocusGained

The node or a descendant inside it gained keyboard focus.

§

KeyUp

A key was released while the node held focus.

Fields

§key: Key
§shift_key: bool
§ctrl_key: bool
§alt_key: bool
§meta_key: bool
§repeat: bool

Always false: a release does not repeat. Present so a key-up carries the same fields as a key-down.

§code: u32

The physical key as a USB HID usage value, the same on every layout.

§text: &'a str

The DOM key string, such as "ArrowDown" or "a".

§

CodeMetrics

The height of one row of a code editor in physical pixels, as it is drawn. Sent when the editor is first drawn and whenever the height changes.

Fields

§line_height_px: f64
§

CodeScrolled

How far a code editor is scrolled down, in physical pixels. At most once a frame.

Fields

§offset_px: f64
§

FileDialogResult

A file dialog ended. request is the number the Host gave it, filter is the position of the filter in use (u32::MAX when there is none) and paths holds the chosen paths separated by one NUL byte, empty unless the status is Chosen. Delivered to the Host itself, with no node and no handler.

Fields

§request: u32
§filter: u32
§paths: &'a str
§

ClipboardText

One clipboard read ended. request is the number the Host gave it, status is a word from clipboard::read_status, len is the text’s length in UTF-8 bytes and text the text itself, empty unless the status is text. Delivered to the Host itself, with no node and no handler.

Fields

§request: u32
§status: u32
§len: u32
§text: &'a str
§

IoAnswer

The one answer to an input or output request: a storage operation the browser carried out, or an operation on a file picked on the web. request is the number the Host gave it, and data is what the operation hands back: a value or a file that was read, or the keys joined by NUL, and nothing for an operation that only writes. Delivered to the Host itself, with no node and no handler.

Fields

§request: u32
§status: IoStatus
§data: &'a [u8]
§

FileHandles

Files the Renderer now holds handles for: the answer to a file dialog that was chosen, or to a folder’s Entries or Child. The handles are first_handle, first_handle + 1 and so on, one per name. names holds the names separated by one NUL byte and kinds one letter per name, f for a file and d for a folder. filter is the position of the filter in use, u32::MAX when there is none. Delivered to the Host itself, with no node and no handler.

Fields

§request: u32
§filter: u32
§delivery: FileDelivery
§first_handle: u32
§names: &'a str
§kinds: &'a str
§

StorageLocation(&'a str)

Where the application’s storage lives on a platform whose Host cannot work it out from the environment: Android’s application files directory, which only a Context knows. Sent once by that Renderer at start. Delivered to the Host itself.

§

ScrollChanged

Where a scroll container is, reported by the Renderer to the node’s OnScrollChanged handler: at most once a frame while it moves, and once more with settled when it stops. Every length is in physical pixels, the unit the Renderer scrolls in, so a value read here and sent back in a ScrollTo is the same place.

In a lazy list item is the first visible item and the main-axis offset is the distance into that item; the list does not know its whole length, so its main-axis max is -1.0. Elsewhere item is 0.

Fields

§item: u32
§settled: bool

The movement ended: a drag, a fling or an animation came to rest.

§can_scroll_backward: bool

The container can still scroll towards the start of its main axis.

§can_scroll_forward: bool

The container can still scroll towards the end of its main axis.

§x_px: f64
§y_px: f64
§max_x_px: f64
§max_y_px: f64
§viewport_width_px: f64
§viewport_height_px: f64

Trait Implementations§

Source§

impl<'a> Clone for EventPayload<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for EventPayload<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for EventPayload<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for EventPayload<'a>

Auto Trait Implementations§

§

impl<'a> Forget for EventPayload<'a>

§

impl<'a> Freeze for EventPayload<'a>

§

impl<'a> Move for EventPayload<'a>

§

impl<'a> RefUnwindSafe for EventPayload<'a>

§

impl<'a> Send for EventPayload<'a>

§

impl<'a> Sync for EventPayload<'a>

§

impl<'a> Unpin for EventPayload<'a>

§

impl<'a> UnsafeUnpin for EventPayload<'a>

§

impl<'a> UnwindSafe for EventPayload<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.