Skip to content

Commit

Permalink
Add meu item for disabled buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Sep 27, 2024
1 parent 2006ebe commit cf6a354
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/widget/menu/menu_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ pub fn menu_button<'a, Message: 'a>(
pub enum MenuItem<A: MenuAction, L: Into<Cow<'static, str>>> {
/// Represents a button menu item.
Button(L, A),
/// Represents a button menu item that is disabled.
ButtonDisabled(L, A),
/// Represents a checkbox menu item.
CheckBox(L, bool, A),
/// Represents a folder menu item.
Expand Down Expand Up @@ -250,6 +252,16 @@ where

trees.push(MenuTree::<Message, Renderer>::new(menu_button));
}
MenuItem::ButtonDisabled(label, action) => {
let key = find_key(&action, key_binds);
let menu_button = menu_button(vec![
widget::text(label).into(),
widget::horizontal_space(Length::Fill).into(),
widget::text(key).into(),
]);

trees.push(MenuTree::<Message, Renderer>::new(menu_button));
}
MenuItem::CheckBox(label, value, action) => {
let key = find_key(&action, key_binds);
trees.push(MenuTree::new(
Expand Down

0 comments on commit cf6a354

Please sign in to comment.