pub struct MenuState { /* private fields */ }Expand description
Retained commands and cursor for one non-modal menu in one window.
The nested PopoverState exclusively owns open, disabled, dismissal, and
focus-restoration behavior. The menu adds enabled-item navigation and command
events. It never stores a selected value: repeated activation of the same
command emits an event each time.
Keep its matching crate::DropdownMenu, crate::ContextMenu,
crate::MenubarMenu or MenuSubmenu mounted while closed and host the app
in crate::Root. Empty and all-disabled collections may open, but cannot
emit commands. Menu options are not individual Tab stops.
Implementations§
Source§impl MenuState
impl MenuState
pub fn new( items: impl IntoIterator<Item = MenuItem>, cx: &mut Context<'_, Self>, ) -> Self
pub fn items(&self) -> &[MenuItem]
pub fn highlighted_index(&self) -> Option<usize>
pub fn is_open(&self, cx: &App) -> bool
pub fn is_disabled(&self, cx: &App) -> bool
Sourcepub fn focus_handle(&self) -> &FocusHandle
pub fn focus_handle(&self) -> &FocusHandle
The button or context target’s focus handle.
Sourcepub fn content_focus_handle(&self) -> &FocusHandle
pub fn content_focus_handle(&self) -> &FocusHandle
The menu’s focus handle; keyboard navigation moves its active descendant.
pub fn set_disabled( &mut self, disabled: bool, window: &mut Window, cx: &mut Context<'_, Self>, )
Trait Implementations§
impl EventEmitter<MenuEvent> for MenuState
Auto Trait Implementations§
impl !RefUnwindSafe for MenuState
impl !Send for MenuState
impl !Sync for MenuState
impl !UnwindSafe for MenuState
impl Forget for MenuState
impl Freeze for MenuState
impl Move for MenuState
impl Unpin for MenuState
impl UnsafeUnpin for MenuState
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more