pub struct MenuWidget {
pub items: Vec<MenuItem>,
pub selected: usize,
pub open: bool,
pub title: Option<String>,
pub scroll: usize,
}Expand description
Menu widget
Fields§
§items: Vec<MenuItem>Menu items
selected: usizeSelected item index
open: boolWhether menu is open
title: Option<String>Menu title
scroll: usizeScroll offset for large menus
Implementations§
Source§impl MenuWidget
impl MenuWidget
Sourcepub fn with_title(title: impl Into<String>) -> Self
pub fn with_title(title: impl Into<String>) -> Self
Create a menu with a title
Sourcepub fn select_next(&mut self)
pub fn select_next(&mut self)
Select next item
Sourcepub fn select_prev(&mut self)
pub fn select_prev(&mut self)
Select previous item
Sourcepub fn select_first(&mut self)
pub fn select_first(&mut self)
Jump to first item
Sourcepub fn select_last(&mut self)
pub fn select_last(&mut self)
Jump to last item
Sourcepub fn selected_item(&self) -> Option<&MenuItem>
pub fn selected_item(&self) -> Option<&MenuItem>
Get selected item
Sourcepub fn selected_index(&self) -> usize
pub fn selected_index(&self) -> usize
Get selected item index
Sourcepub fn visible_items(&self, height: usize) -> Vec<(usize, &MenuItem)>
pub fn visible_items(&self, height: usize) -> Vec<(usize, &MenuItem)>
Get visible items based on scroll
Sourcepub fn item_count(&self) -> usize
pub fn item_count(&self) -> usize
Get total item count
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MenuWidget
impl RefUnwindSafe for MenuWidget
impl Send for MenuWidget
impl Sync for MenuWidget
impl Unpin for MenuWidget
impl UnwindSafe for MenuWidget
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> 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