pub struct State<Id, Key = ()> { /* private fields */ }context-menu only.Expand description
The menu, which area it opened on and where.
Implementations§
Source§impl<Id: Copy + PartialEq, Key: Clone + PartialEq> State<Id, Key>
impl<Id: Copy + PartialEq, Key: Clone + PartialEq> State<Id, Key>
Sourcepub fn new(entries: impl IntoIterator<Item = Entry<Id>>) -> Self
pub fn new(entries: impl IntoIterator<Item = Entry<Id>>) -> Self
A closed menu. Item ids must be unique across submenus.
The menu entries, highlight and open submenus.
pub fn is_open(&self) -> bool
Sourcepub fn is_open_on(&self, key: &Key) -> bool
pub fn is_open_on(&self, key: &Key) -> bool
Whether the menu is open on the area key.
Sourcepub fn target(&self) -> Option<&Key>
pub fn target(&self) -> Option<&Key>
The area the menu last opened on. It stays set after the menu closes, so the app can tell which row a chosen item belongs to.
Sourcepub fn position(&self) -> Option<Point>
pub fn position(&self) -> Option<Point>
Where a right-click opened the menu, relative to the area’s top left
corner, or None when it opened from the keyboard below the area.
pub fn is_checked(&self, id: Id) -> bool
Sourcepub fn set_checked(&mut self, id: Id, checked: bool)
pub fn set_checked(&mut self, id: Id, checked: bool)
Checks or unchecks an item. Checking a radio item unchecks its group.
pub fn set_disabled(&mut self, id: Id, disabled: bool)
Sourcepub fn update(&mut self, event: Event<Id, Key>) -> Option<Output<Id>>
pub fn update(&mut self, event: Event<Id, Key>) -> Option<Output<Id>>
Applies an event and returns what was chosen, if anything. Opening on another area moves the menu there and resets it.
Sourcepub fn key_event(
&self,
keymap: &Keymap<Action>,
key: &Event,
target: Key,
) -> Option<Event<Id, Key>>
pub fn key_event( &self, keymap: &Keymap<Action>, key: &Event, target: Key, ) -> Option<Event<Id, Key>>
Turns a key press into an event: first through keymap, then, while
the menu is open, as typeahead for a letter or digit. target is the
area the opening chord opens the menu on, such as the focused row;
pass () for a menu with a single area.
Trait Implementations§
impl<Id: PartialEq, Key: PartialEq> StructuralPartialEq for State<Id, Key>
Auto Trait Implementations§
impl<Id, Key> Freeze for State<Id, Key>
impl<Id, Key> RefUnwindSafe for State<Id, Key>
impl<Id, Key> Send for State<Id, Key>
impl<Id, Key> Sync for State<Id, Key>
impl<Id, Key> Unpin for State<Id, Key>
impl<Id, Key> UnsafeUnpin for State<Id, Key>
impl<Id, Key> UnwindSafe for State<Id, Key>
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.