#[repr(C)]pub struct Menu {
pub items: MenuItemVec,
pub position: MenuPopupPosition,
pub context_mouse_btn: ContextMenuMouseButton,
}Expand description
Represents a menu (context menu, dropdown menu, or application menu).
A menu consists of a list of items that can be displayed as a popup or attached to a window’s menu bar. Modeled after the Windows API for cross-platform consistency.
§Fields
items- The menu items to displayposition- Where the menu should appear (for popups)context_mouse_btn- Which mouse button triggers the context menu
Fields§
§items: MenuItemVec§position: MenuPopupPosition§context_mouse_btn: ContextMenuMouseButtonImplementations§
Source§impl Menu
impl Menu
Sourcepub fn create(items: MenuItemVec) -> Self
pub fn create(items: MenuItemVec) -> Self
Creates a new menu with the given items.
Uses default position (AutoCursor) and right mouse button for context menus.
Sourcepub fn with_position(self, position: MenuPopupPosition) -> Self
pub fn with_position(self, position: MenuPopupPosition) -> Self
Builder method to set the popup position.
Source§impl Menu
impl Menu
Sourcepub fn swap_with_default(&mut self) -> Self
pub fn swap_with_default(&mut self) -> Self
Swaps this menu with a default menu and returns the previous contents.
This is useful for taking ownership of the menu’s contents without cloning.
Trait Implementations§
Source§impl Ord for Menu
impl Ord for Menu
Source§impl PartialOrd for Menu
impl PartialOrd for Menu
impl Eq for Menu
impl StructuralPartialEq for Menu
Auto Trait Implementations§
impl Freeze for Menu
impl RefUnwindSafe for Menu
impl Send for Menu
impl Sync for Menu
impl Unpin for Menu
impl UnwindSafe for Menu
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more