Skip to content

Add separator / grayed flag support#398

Merged
emoon merged 18 commits intoemoon:masterfrom
ZX-80:patch-1
Mar 14, 2026
Merged

Add separator / grayed flag support#398
emoon merged 18 commits intoemoon:masterfrom
ZX-80:patch-1

Conversation

@ZX-80
Copy link
Copy Markdown
Contributor

@ZX-80 ZX-80 commented Mar 10, 2026

Problem: Windows menus had not yet implemented separators or greyed out menus when disabled.

Solution:

  • Set the MF_GRAYED flag if disabled
  • Append a separator if the ID is MENU_ID_SEPARATOR

To toggle the state, an enable_menu function was added. You use it like this. Let me know if that fits the style of this project or if stubs are needed for other os modules

// Menu 1
let mut menu_1 = Menu::new("Menu 1").unwrap();
menu_1.add_item("Item 1", 1).build();
menu_1.add_item("Item 2", 2).build();

// Menu 2
let mut menu_2 = Menu::new("Menu 2").unwrap();
menu_2.add_item("Item 1", 3).build();
menu_2.add_item("Item 2", 4).build();

let menu_1_handle = window.add_menu(&menu_1 );
let menu_2_handle = window.add_menu(&menu_2 );

// Disable the second item in menu 1
window.enable_menu(Some(menu_1_handle ), 1, false);
// Disable menu 2
window.enable_menu(None, 1, false);
Screenshot 2026-03-10 191211

@emoon emoon merged commit e29774f into emoon:master Mar 14, 2026
4 checks passed
@emoon
Copy link
Copy Markdown
Owner

emoon commented Mar 14, 2026

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants