pub struct ContextMenuState {
pub is_open: bool,
pub anchor_position: (u16, u16),
pub highlighted_index: usize,
pub scroll_offset: u16,
pub active_submenu: Option<usize>,
pub submenu_state: Option<Box<ContextMenuState>>,
}Expand description
State for a context menu.
Fields§
§is_open: boolWhether the menu is currently open.
anchor_position: (u16, u16)Anchor position (x, y) where menu appears.
highlighted_index: usizeCurrently highlighted item index.
scroll_offset: u16Scroll offset for long menus.
Index of active submenu (if any).
State for active submenu (boxed to avoid infinite size).
Implementations§
Source§impl ContextMenuState
impl ContextMenuState
Sourcepub fn highlight_prev(&mut self, items: &[ContextMenuItem])
pub fn highlight_prev(&mut self, items: &[ContextMenuItem])
Move highlight to previous selectable item.
Sourcepub fn highlight_next(&mut self, items: &[ContextMenuItem])
pub fn highlight_next(&mut self, items: &[ContextMenuItem])
Move highlight to next selectable item.
Sourcepub fn highlight_first(&mut self, items: &[ContextMenuItem])
pub fn highlight_first(&mut self, items: &[ContextMenuItem])
Move to first selectable item.
Sourcepub fn highlight_last(&mut self, items: &[ContextMenuItem])
pub fn highlight_last(&mut self, items: &[ContextMenuItem])
Move to last selectable item.
Open submenu at the highlighted index.
Close any open submenu.
Check if a submenu is open.
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 ContextMenuState
impl Clone for ContextMenuState
Source§fn clone(&self) -> ContextMenuState
fn clone(&self) -> ContextMenuState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContextMenuState
impl Debug for ContextMenuState
Auto Trait Implementations§
impl Freeze for ContextMenuState
impl RefUnwindSafe for ContextMenuState
impl Send for ContextMenuState
impl Sync for ContextMenuState
impl Unpin for ContextMenuState
impl UnwindSafe for ContextMenuState
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
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>
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