mirror of
https://github.com/italicsjenga/muda.git
synced 2025-01-11 12:21:30 +11:00
feat: expose macOS NSMenu
This commit is contained in:
parent
812ff0d37a
commit
37153b826f
|
@ -209,6 +209,9 @@ pub trait ContextMenu {
|
||||||
/// (the click which triggered the menu to be shown).
|
/// (the click which triggered the menu to be shown).
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
fn show_context_menu_for_nsview(&self, view: cocoa::base::id, x: f64, y: f64);
|
fn show_context_menu_for_nsview(&self, view: cocoa::base::id, x: f64, y: f64);
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
fn ns_menu(&self) -> *mut std::ffi::c_void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Describes a menu event emitted when a menu item is activated
|
/// Describes a menu event emitted when a menu item is activated
|
||||||
|
|
|
@ -46,6 +46,11 @@ impl ContextMenu for Menu {
|
||||||
fn show_context_menu_for_nsview(&self, view: cocoa::base::id, x: f64, y: f64) {
|
fn show_context_menu_for_nsview(&self, view: cocoa::base::id, x: f64, y: f64) {
|
||||||
self.0.show_context_menu_for_nsview(view, x, y)
|
self.0.show_context_menu_for_nsview(view, x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
fn ns_menu(&self) -> *mut std::ffi::c_void {
|
||||||
|
self.0.ns_menu()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Menu {
|
impl Menu {
|
||||||
|
|
|
@ -242,6 +242,10 @@ impl Menu {
|
||||||
msg_send![self.ns_menu, popUpMenuPositioningItem: nil atLocation: location inView: view]
|
msg_send![self.ns_menu, popUpMenuPositioningItem: nil atLocation: location inView: view]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn ns_menu(&self) -> *mut std::ffi::c_void {
|
||||||
|
self.ns_menu as _
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -446,6 +450,19 @@ impl Submenu {
|
||||||
unsafe { msg_send![NSApp(), setHelpMenu: ns_menus[0]] }
|
unsafe { msg_send![NSApp(), setHelpMenu: ns_menus[0]] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn ns_menu(&self) -> *mut std::ffi::c_void {
|
||||||
|
*self
|
||||||
|
.0
|
||||||
|
.borrow()
|
||||||
|
.ns_menus
|
||||||
|
.values()
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.get(0)
|
||||||
|
.unwrap()
|
||||||
|
.get(0)
|
||||||
|
.unwrap() as _
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
|
@ -54,6 +54,11 @@ impl ContextMenu for Submenu {
|
||||||
fn show_context_menu_for_nsview(&self, view: cocoa::base::id, x: f64, y: f64) {
|
fn show_context_menu_for_nsview(&self, view: cocoa::base::id, x: f64, y: f64) {
|
||||||
self.0.show_context_menu_for_nsview(view, x, y)
|
self.0.show_context_menu_for_nsview(view, x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
fn ns_menu(&self) -> *mut std::ffi::c_void {
|
||||||
|
self.0.ns_menu()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Submenu {
|
impl Submenu {
|
||||||
|
|
Loading…
Reference in a new issue