pub struct MenuEvent {
pub id: String,
pub sequence: u64,
}Expand description
The menu-activation read surface (frust-reactive’s process-wide menu
source — see its module docs): a per-OS desktop shell drains its native menu
queue once per frame and reports each activation, and app code observes it
here. menu_events() returns the live MenuEvents handle whose latest
signal carries a MenuEvent — the activated item’s id exactly as the
app wrote it in its MenuSpec, plus a monotonic sequence so choosing
the same item twice reads as two activations rather than one stale value.
use frust::{AnyView, Component, Get, any, menu_events, text};
#[derive(Default)]
struct MenuDemo;
impl Component for MenuDemo {
type State = ();
fn init(&self) -> Self::State {}
fn build(&self, _state: &mut Self::State) -> AnyView<Self::State> {
// A tracked read: this rebuild re-runs when an item is activated.
let label = match menu_events().latest.get() {
Some(event) => format!("chose {}", event.id),
None => "nothing chosen yet".to_string(),
};
any(text(label))
}
}Available on every target, unlike the MenuSpec vocabulary that
describes the menu itself: a component reading menu events compiles on
Android/iOS too (where nothing ever pushes one), so shared component code
needs no cfg of its own.
Unlike push_deep_link, the push side is deliberately not
re-exported: a menu activation has exactly one producer — the per-OS shell
that owns the platform menu — and nothing in an app simulates one the way
examples/navdemo simulates a warm deep link.
One delivered menu activation: the id the app gave the item in its
MenuSpec (e.g. "file.open"), plus the process-wide sequence number of
this activation (see the module docs). The id is passed through verbatim —
mapping it to an action is app code’s job, not this crate’s.
Fields§
§id: StringThe activated item’s app-chosen id, exactly as it appeared in the
MenuSpec the shell was configured with.
sequence: u64This activation’s position in the process-wide activation sequence,
starting at 1 for the first push. Strictly increasing, so glue can
dedupe by “the last sequence I consumed” and tell a repeat activation of
the same id apart from a re-read of the previous one.
Implementations§
Trait Implementations§
impl Eq for MenuEvent
impl StructuralPartialEq for MenuEvent
Auto Trait Implementations§
impl Freeze for MenuEvent
impl RefUnwindSafe for MenuEvent
impl Send for MenuEvent
impl Sync for MenuEvent
impl Unpin for MenuEvent
impl UnsafeUnpin for MenuEvent
impl UnwindSafe for MenuEvent
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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.