pub struct MenuBarState {
pub is_open: bool,
pub active_menu: usize,
pub highlighted_item: Option<usize>,
pub scroll_offset: u16,
pub focused: bool,
pub active_submenu: Option<usize>,
pub submenu_highlighted: Option<usize>,
pub submenu_scroll_offset: u16,
}Expand description
State for a menu bar.
Fields§
§is_open: boolWhether any menu is currently open.
Index of the currently active/highlighted menu (always set when focused).
highlighted_item: Option<usize>Currently highlighted item index within the dropdown (if open).
scroll_offset: u16Scroll offset for long dropdown menus.
focused: boolWhether the menu bar has focus.
Index of active submenu item (if any).
State for active submenu.
Submenu scroll offset.
Implementations§
Source§impl MenuBarState
impl MenuBarState
Open the menu at the given index.
Close any open menu.
Toggle the menu at the given index.
Move to the next menu in the bar.
Move to the previous menu in the bar.
Sourcepub fn next_item(&mut self, items: &[MenuBarItem])
pub fn next_item(&mut self, items: &[MenuBarItem])
Move highlight to the next item in the dropdown.
Sourcepub fn prev_item(&mut self, items: &[MenuBarItem])
pub fn prev_item(&mut self, items: &[MenuBarItem])
Move highlight to the previous item in the dropdown.
Sourcepub fn highlight_first(&mut self, items: &[MenuBarItem])
pub fn highlight_first(&mut self, items: &[MenuBarItem])
Move to first selectable item.
Sourcepub fn highlight_last(&mut self, items: &[MenuBarItem])
pub fn highlight_last(&mut self, items: &[MenuBarItem])
Move to last selectable item.
Sourcepub fn select_item(&mut self, index: usize)
pub fn select_item(&mut self, index: usize)
Select an item by index.
Open submenu at the highlighted index.
Close any open submenu.
Check if a submenu is open.
Move to next item in submenu.
Move to previous item in submenu.
Sourcepub fn ensure_visible(&mut self, viewport_height: usize)
pub fn ensure_visible(&mut self, viewport_height: usize)
Ensure highlighted item is visible in viewport.
Trait Implementations§
Source§impl Clone for MenuBarState
impl Clone for MenuBarState
Source§fn clone(&self) -> MenuBarState
fn clone(&self) -> MenuBarState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MenuBarState
impl Debug for MenuBarState
Auto Trait Implementations§
impl Freeze for MenuBarState
impl RefUnwindSafe for MenuBarState
impl Send for MenuBarState
impl Sync for MenuBarState
impl Unpin for MenuBarState
impl UnwindSafe for MenuBarState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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