Fixed shortcuts on Mac

This commit is contained in:
Daniel Collin 2016-05-08 08:55:22 +02:00
parent 42ce3b9286
commit 25ed203497
3 changed files with 8 additions and 5 deletions

View file

@ -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));

View file

@ -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];
}
}

View file

@ -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))
}
}