Trait ContextMenu

Source
pub trait ContextMenu {
    // Required methods
    fn hpopupmenu(&self) -> isize;
    unsafe fn show_context_menu_for_hwnd(
        &self,
        hwnd: isize,
        position: Option<Position>,
    ) -> bool;
    unsafe fn attach_menu_subclass_for_hwnd(&self, hwnd: isize);
    unsafe fn detach_menu_subclass_from_hwnd(&self, hwnd: isize);
}
Expand description

A helper trait with methods to help creating a context menu.

Required Methods§

Source

fn hpopupmenu(&self) -> isize

Get the popup HMENU for this menu.

The returned HMENU is valid as long as the ContextMenu is.

Source

unsafe fn show_context_menu_for_hwnd( &self, hwnd: isize, position: Option<Position>, ) -> bool

Shows this menu as a context menu inside a win32 window.

  • position is relative to the window top-left corner, if None, 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 hwnd must be a valid window HWND.

Source

unsafe fn attach_menu_subclass_for_hwnd(&self, hwnd: isize)

Attach the menu subclass handler to the given hwnd so you can recieve events from that window using MenuEvent::receiver

This can be used along with ContextMenu::hpopupmenu when implementing a tray icon menu.

§Safety

The hwnd must be a valid window HWND.

Source

unsafe fn detach_menu_subclass_from_hwnd(&self, hwnd: isize)

Remove the menu subclass handler from the given hwnd

The view must be a pointer to a valid NSView.

§Safety

The hwnd must be a valid window HWND.

Implementors§