Struct native_windows_gui::Menu
source · [−]pub struct Menu {
pub handle: ControlHandle,
}
Expand description
A windows menu. Can represent a menu in a window menubar, a context menu, or a submenu in another menu
Requires the menu
feature.
Builder parameters:
- text: The text of the menu
- disabled: If the menu can be selected by the user
- popup: The menu is a context menu
- parent: A top level window, a menu or None. With a top level window, the menu is added to the menu bar if popup is set to false.
Control events:
- OnMenuOpen: Sent when a drop-down menu or submenu is about to become active.
- OnMenuHover: When the user hovers the menu
- OnMenuEnter: When the user enters the menu. Technically, when the user enters the menu modal loop.
- OnMenuExit: When the menu is closed. Technically, when the user exits the menu modal loop.
Menu Access Keys
Menu can have access keys. An access key is an underlined letter in the text of a menu item. When a menu is active, the user can select a menu item by pressing the key that corresponds to the item’s underlined letter. The user makes the menu bar active by pressing the ALT key to highlight the first item on the menu bar. A menu is active when it is displayed.
To create an access key for a menu item, precede any character in the item’s text string with an ampersand. For example, the text string “&Move” causes the system to underline the letter “M”.
use native_windows_gui as nwg;
fn menu(menu: &mut nwg::Menu, window: &nwg::Window) -> Result<(), nwg::NwgError> {
nwg::Menu::builder()
.text("&Hello")
.disabled(false)
.parent(window)
.build(menu)
}
Fields
handle: ControlHandle
Implementations
sourceimpl Menu
impl Menu
pub fn builder<'a>() -> MenuBuilder<'a>
sourcepub fn enabled(&self) -> bool
pub fn enabled(&self) -> bool
Return true if the control user can interact with the control, return false otherwise
sourcepub fn set_enabled(&self, v: bool)
pub fn set_enabled(&self, v: bool)
Enable or disable the control A popup menu cannot be disabled
sourcepub fn popup_with_flags(&self, x: i32, y: i32, flags: PopupMenuFlags)
pub fn popup_with_flags(&self, x: i32, y: i32, flags: PopupMenuFlags)
Show a popup menu as the selected position. Do nothing for menubar menu.
Trait Implementations
sourceimpl From<&Menu> for ControlHandle
impl From<&Menu> for ControlHandle
sourceimpl From<&mut Menu> for ControlHandle
impl From<&mut Menu> for ControlHandle
sourceimpl PartialEq<ControlHandle> for Menu
impl PartialEq<ControlHandle> for Menu
sourcefn eq(&self, other: &ControlHandle) -> bool
fn eq(&self, other: &ControlHandle) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl PartialEq<Menu> for ControlHandle
impl PartialEq<Menu> for ControlHandle
sourceimpl PartialEq<Menu> for Menu
impl PartialEq<Menu> for Menu
impl Eq for Menu
impl StructuralEq for Menu
impl StructuralPartialEq for Menu
Auto Trait Implementations
impl RefUnwindSafe for Menu
impl !Send for Menu
impl !Sync for Menu
impl Unpin for Menu
impl UnwindSafe for Menu
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more