diff --git a/examples/menu.rs b/examples/menu.rs index 56bcb09..2a0487b 100644 --- a/examples/menu.rs +++ b/examples/menu.rs @@ -90,7 +90,7 @@ fn main() { let mut menu = Menu::new("TestMenu").unwrap(); - menu.add_item(&MenuItem::new("Item 1", 1)); + menu.add_item(&MenuItem::new("Item 1", 1).shortcut(Key::S, 0)); menu.add_item(&MenuItem::new("Item 2", 2)); menu.add_item(&MenuItem::new("Item 3", 3)); diff --git a/src/native/macosx/OSXWindow.m b/src/native/macosx/OSXWindow.m index 625c585..cdc1b5f 100644 --- a/src/native/macosx/OSXWindow.m +++ b/src/native/macosx/OSXWindow.m @@ -372,11 +372,11 @@ uint64_t mfb_add_menu_item( } if (key != 0x7f) { - NSString* key = convert_key_code_to_string(key); + NSString* key_string = convert_key_code_to_string(key); - if (key) { + if (key_string) { [newItem setKeyEquivalentModifierMask: mask]; - [newItem setKeyEquivalent:key]; + [newItem setKeyEquivalent:key_string]; } } diff --git a/src/os/macos/mod.rs b/src/os/macos/mod.rs index 93c7dbb..133209e 100644 --- a/src/os/macos/mod.rs +++ b/src/os/macos/mod.rs @@ -191,6 +191,7 @@ extern { fn mfb_add_menu_item(menu_item: *mut c_void, menu_id: i32, name: *const c_char, + enabled: bool, key: u32, modifier: u32) -> u64; fn mfb_remove_menu_item(menu: *mut c_void, item_handle: u64); @@ -623,7 +624,9 @@ impl Menu { println!("key {:?} conv {}", item.key, conv_key); MenuItemHandle(mfb_add_menu_item(self.menu_handle, item.id as i32, item_name.as_ptr(), - Self::map_key_to_menu_key(item.key), item.modifier)) + item.enabled, + Self::map_key_to_menu_key(item.key), + item.modifier)) } }