pub struct Menu {
pub items: Vec<MenuItem>,
pub default_index: Option<usize>,
}Expand description
Menu - a collection of menu items
Matches Borland: TMenu
In Borland, TMenu has:
items: pointer to first item in linked listdeflt: pointer to default item
In Rust, we use Vec for type safety and provide convenient builders.
Fields§
§items: Vec<MenuItem>Menu items
default_index: Option<usize>Index of default item (if any)
Implementations§
Source§impl Menu
impl Menu
Sourcepub fn from_items(items: Vec<MenuItem>) -> Self
pub fn from_items(items: Vec<MenuItem>) -> Self
Create a menu from items
Matches Borland: TMenu(itemList)
Sourcepub fn with_default(items: Vec<MenuItem>, default_index: usize) -> Self
pub fn with_default(items: Vec<MenuItem>, default_index: usize) -> Self
Create a menu with a default item
Matches Borland: TMenu(itemList, deflt)
Sourcepub fn add(&mut self, item: MenuItem)
pub fn add(&mut self, item: MenuItem)
Add an item to the menu
Matches Borland: appending to TMenuItem linked list
Sourcepub fn find_hotkey(&self, key_code: KeyCode) -> Option<CommandId>
pub fn find_hotkey(&self, key_code: KeyCode) -> Option<CommandId>
Find the command bound to a keyboard shortcut, searching submenus.
Matches Borland: TMenuView::findHotKey() — lets item shortcuts like F2
work while the menu is closed.
Sourcepub fn set_default(&mut self, index: usize)
pub fn set_default(&mut self, index: usize)
Set the default item by index
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Menu
impl RefUnwindSafe for Menu
impl Send for Menu
impl Sync for Menu
impl Unpin for Menu
impl UnsafeUnpin for Menu
impl UnwindSafe for Menu
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