#[repr(C)]pub struct StringMenuItem {
pub label: AzString,
pub accelerator: OptionVirtualKeyCodeCombo,
pub callback: OptionCoreMenuCallback,
pub menu_item_state: MenuItemState,
pub icon: OptionMenuItemIcon,
pub children: MenuItemVec,
}Expand description
A menu item with a text label and optional features.
StringMenuItem represents a clickable menu entry that can have:
- A text label
- An optional keyboard accelerator (e.g., Ctrl+C)
- An optional callback function
- An optional icon (checkbox or image)
- A state (normal, greyed, or disabled)
- Child menu items (for sub-menus)
Fields§
§label: AzStringLabel of the menu (ex. “File”, “Edit”, “View”)
accelerator: OptionVirtualKeyCodeComboOptional accelerator combination (ex. “CTRL + X” = [VirtualKeyCode::Ctrl, VirtualKeyCode::X]) for keyboard shortcut
callback: OptionCoreMenuCallbackOptional callback to call
State (normal, greyed, disabled)
icon: OptionMenuItemIconOptional icon for the menu entry
children: MenuItemVecSub-menus of this item (separators and line-breaks can’t have sub-menus)
Implementations§
Source§impl StringMenuItem
impl StringMenuItem
Sourcepub const fn create(label: AzString) -> Self
pub const fn create(label: AzString) -> Self
Creates a new menu item with the given label.
All optional fields default to None / Normal.
Sourcepub fn with_children(self, children: MenuItemVec) -> Self
pub fn with_children(self, children: MenuItemVec) -> Self
Sets the child menu items for this item, creating a sub-menu.
Sourcepub fn with_child(self, child: MenuItem) -> Self
pub fn with_child(self, child: MenuItem) -> Self
Adds a single child menu item to this item.
Sourcepub fn with_callback<I: Into<CoreCallback>>(
self,
data: RefAny,
callback: I,
) -> Self
pub fn with_callback<I: Into<CoreCallback>>( self, data: RefAny, callback: I, ) -> Self
Attaches a callback function to this menu item.
§Parameters
data- User data passed to the callbackcallback- Function pointer (as usize) to invoke when item is clicked
§Note
This uses CoreCallbackType (usize) instead of a real function pointer
to avoid circular dependencies. The conversion happens in azul-layout.
Trait Implementations§
Source§impl Clone for StringMenuItem
impl Clone for StringMenuItem
Source§fn clone(&self) -> StringMenuItem
fn clone(&self) -> StringMenuItem
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StringMenuItem
impl Debug for StringMenuItem
Source§impl Hash for StringMenuItem
impl Hash for StringMenuItem
Source§impl Ord for StringMenuItem
impl Ord for StringMenuItem
Source§fn cmp(&self, other: &StringMenuItem) -> Ordering
fn cmp(&self, other: &StringMenuItem) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for StringMenuItem
impl PartialEq for StringMenuItem
Source§fn eq(&self, other: &StringMenuItem) -> bool
fn eq(&self, other: &StringMenuItem) -> bool
self and other values to be equal, and is used by ==.