Trait ContextMenu

pub trait ContextMenu {
    // Required methods
    fn show_context_menu_for_gtk_window(
        &self,
        w: &Window,
        position: Option<Position>,
    ) -> bool;
    fn gtk_context_menu(&self) -> Menu;

    // 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 { ... }
}
Expand description

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

Required Methods§

fn show_context_menu_for_gtk_window( &self, w: &Window, position: Option<Position>, ) -> bool

Shows this menu as a context menu inside a [gtk::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 or clicked outside the menu to dismiss it.

Returns false if menu tracking was cancelled for any reason.

fn gtk_context_menu(&self) -> Menu

Get the underlying gtk menu reserved for context menus.

The returned [gtk::Menu] is valid as long as the ContextMenu is.

Provided Methods§

fn as_menu(&self) -> Option<&Menu>

Cast this context menu to a Menu, and returns None if it wasn’t.

fn as_menu_unchecked(&self) -> &Menu

Casts this context menu to a Menu, and panics if it wasn’t.

fn as_submenu(&self) -> Option<&Submenu>

Cast this context menu to a Submenu, and returns None if it wasn’t.

fn as_submenu_unchecked(&self) -> &Menu

Casts this context menu to a Submenu, and panics if it wasn’t.

Implementors§