Skip to main content

UiEvent

Struct UiEvent 

Source
pub struct UiEvent {
    pub origin: OriginId,
    pub window: WindowId,
    pub key: Key,
    pub payload: Value,
    pub slot: Option<Key>,
}
Expand description

An event produced by the UI, ready for routing.

Fields§

§origin: OriginId§window: WindowId

Which window the event came from — a new field and not a second reading of origin, which says which frontend drew the node and answers HOST for a window an extension also draws into.

Most producers cannot fill it in: a hit test and the edit buffer know nothing about windows. They leave it WindowId::MAIN and the core stamps its own env.window.id over it as the event leaves (Core::handle_input, Core::take_pending_events) — one core is one window, so that is the whole answer. The audio store is the exception: its mounts are per window, so a sound event carries the window that declared the node and the stamp leaves it alone. A driver that builds an event itself stamps it itself.

§key: Key§payload: Value§slot: Option<Key>

The slot whose fill drew the node — its key, the one begin_slot returned and key_of(full_name) answers — or None for a node the host drew itself. What origin cannot say: one extension fills many slots (a Lua host with a view per pane), and an event routed by pane needs the slot, not the extension. Stamped by the core on the way out like window, from the fill ranges the last frame recorded (Tree::fills); a producer leaves it None.

Implementations§

Source§

impl UiEvent

Source

pub fn tag(&self) -> Option<&Value>

The app’s tag inside a core event’s payload — onDrag’s, onKey’s — as sent; UiEvent::message reads it typed.

Source

pub fn drag(&self) -> Option<Drag>

This event as a drag, if it is one.

Source

pub fn button(&self) -> Option<ButtonEvent>

This event as a held non-primary button’s press, move or release, if it is one.

Source

pub fn key_press(&self) -> Option<(KeyPhase, KeyPress)>

This event as a key press or release on a key sink, if it is one (key_press, since key is the node the event is about): the KeyPress the core built it from, so a keymap binds the same value a headless press sends.

Source

pub fn text(&self) -> Option<TextInput<'_>>

This event as inserted text, if it is some.

Source

pub fn scroll(&self) -> Option<Scroll>

This event as a wheel scroll, if it is one.

Source

pub fn hover(&self) -> Option<Hover>

This event as a hover edge, if it is one.

Source

pub fn modifiers(&self) -> Option<KeyMods>

This event as a modifier change, if it is one: the keys now held.

Source

pub fn layout(&self) -> Option<Layout>

This event as an onLayout report, if it is one.

Source§

impl UiEvent

Source

pub fn on(origin: OriginId, key: Key, payload: Value) -> Self

An event as a producer builds it: the window is left WindowId::MAIN and the slot None for the core to stamp on the way out (see UiEvent::window, UiEvent::slot).

Source

pub fn kind(&self) -> Option<&str>

Merges the node’s tag into a map payload. A Null tag declares the behaviour and names nothing, so it is the one value left out — the rule every row with a tag reads by, stated once. The payload’s kind: what a core event says it is — "drag", "key", "scroll" — or the kind of an app’s own map tag. None for a payload that is not a map or has no string kind.

Source

pub fn tagged(self, tag: Option<&Value>) -> Self

Source§

impl UiEvent

Source

pub fn message<M>(&self) -> Option<M>
where M: for<'a> TryFrom<&'a Value>,

The app’s message this event carries, as M: the payload itself for a click (what on_click was handed), and otherwise the tag inside a core event — a drag, a change, a scroll, a drop, a layout — which is what on_drag and the rest were handed. None when neither is an M: a key press, a core event with no tag, another type’s.

The event’s own fields stay on payload — a drag’s phase and x/y, a change’s value — so a handler matches on the message and reads those beside it.

Trait Implementations§

Source§

impl Clone for UiEvent

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 Debug for UiEvent

Source§

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

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

impl PartialEq for UiEvent

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 StructuralPartialEq for UiEvent

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.