pub struct MenuBar {
pub menus: Vec<Menu>,
pub opened_menu: Option<usize>,
pub theme: MenuTheme,
}Expand description
A menu bar widget that will be displayed at the top of the screen.
Only one menu can be open at a time. When a menu is opened, it displays its dropdown and becomes the active menu for keyboard navigation.
Fields§
Collection of menus in the menu bar
Index of the currently opened menu (None means no menu is open)
theme: MenuThemeTheme configuration for rendering
Implementations§
Source§impl MenuBar
impl MenuBar
Creates a new menu bar from menu definitions.
§Example
use tui_vision::menus::{MenuBar, MenuItem};
let menu_bar = MenuBar::from_menus([
("File", Some('F'), vec![
MenuItem::new_action("New", "file.new"),
MenuItem::separator(),
MenuItem::new_action("Exit", "file.exit"),
]),
("Edit", Some('E'), vec![
MenuItem::new_action("Undo", "edit.undo"),
MenuItem::new_action("Redo", "edit.redo"),
]),
]);Creates a new menu bar with the given menus.
§Example
use tui_vision::menus::{MenuBar, Menu};
let menu_bar = MenuBar::with_menus(vec![
Menu::new("File").hotkey('F'),
Menu::new("Edit").hotkey('E'),
]);Adds a menu to the menu bar (builder pattern).
Source§impl MenuBar
impl MenuBar
Sourcepub fn handle_key_event(&mut self, key: KeyEvent) -> MenuEventResult
pub fn handle_key_event(&mut self, key: KeyEvent) -> MenuEventResult
Handles a keyboard event for the menu system.
Returns a MenuEventResult indicating what happened as a result of the key press.
The caller can use this to update status messages, handle commands, etc.
Trait Implementations§
Source§impl StatefulWidget for MenuBar
Stateful widget implementation for cases where you need to pass state.
impl StatefulWidget for MenuBar
Stateful widget implementation for cases where you need to pass state.
Source§impl Widget for MenuBar
Rendering implementation for the MenuBar widget.
impl Widget for MenuBar
Rendering implementation for the MenuBar widget.
This implementation renders the menu bar as a horizontal strip across the top of the terminal, with menus displayed as clickable titles. When a menu is open, it displays a dropdown with the menu items.
impl Eq for MenuBar
impl StructuralPartialEq for MenuBar
Auto Trait Implementations§
impl Freeze for MenuBar
impl RefUnwindSafe for MenuBar
impl Send for MenuBar
impl Sync for MenuBar
impl Unpin for MenuBar
impl UnwindSafe for MenuBar
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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