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: WindowIdWhich 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
impl UiEvent
Sourcepub fn tag(&self) -> Option<&Value>
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.
This event as a held non-primary button’s press, move or release, if it is one.
Sourcepub fn key_press(&self) -> Option<(KeyPhase, KeyPress)>
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§impl UiEvent
impl UiEvent
Sourcepub fn on(origin: OriginId, key: Key, payload: Value) -> UiEvent
pub fn on(origin: OriginId, key: Key, payload: Value) -> UiEvent
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).
Sourcepub fn kind(&self) -> Option<&str>
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.
pub fn tagged(self, tag: Option<&Value>) -> UiEvent
Source§impl UiEvent
impl UiEvent
Sourcepub fn message<M>(&self) -> Option<M>
pub fn message<M>(&self) -> Option<M>
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§
impl StructuralPartialEq for UiEvent
Auto Trait Implementations§
impl Freeze for UiEvent
impl RefUnwindSafe for UiEvent
impl Send for UiEvent
impl Sync for UiEvent
impl Unpin for UiEvent
impl UnsafeUnpin for UiEvent
impl UnwindSafe for UiEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.