Trait ContextMenu
pub trait ContextMenu {
// Required methods
unsafe fn show_context_menu_for_nsview(
&self,
view: *const c_void,
position: Option<Position>,
) -> bool;
fn ns_menu(&self) -> *mut c_void;
// Provided methods
fn as_menu(&self) -> Option<&Menu> { ... }
fn as_menu_unchecked(&self) -> &Menu { ... }
fn as_submenu(&self) -> Option<&Submenu> { ... }
fn as_submenu_unchecked(&self) -> &Menu { ... }
}Available on crate feature
tray only.Expand description
A helper trait with methods to help creating a context menu.
Required Methods§
Shows this menu as a context menu for the specified NSView.
positionis relative to the window top-left corner, ifNone, the cursor position is used.
Returns true if menu tracking ended because an item was selected, and false if menu tracking was cancelled for any reason.
§Safety
The view must be a pointer to a valid NSView.
Get the underlying NSMenu reserved for context menus.
The returned pointer is valid for as long as the ContextMenu is. If
you need it to be alive for longer, retain it.
Provided Methods§
Cast this context menu to a Menu, and returns None if it wasn’t.
Casts this context menu to a Menu, and panics if it wasn’t.
Cast this context menu to a Submenu, and returns None if it wasn’t.
Casts this context menu to a Submenu, and panics if it wasn’t.