#[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 and default values.
Default values:
- No accelerator
- No callback
- Normal state
- No icon
- No children
Sourcepub fn swap_with_default(&mut self) -> Self
pub fn swap_with_default(&mut self) -> Self
Swaps this menu item with a default item and returns the previous contents.
This is useful for taking ownership without cloning.
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 · 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 · 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§impl PartialOrd for StringMenuItem
impl PartialOrd for StringMenuItem
impl Eq for StringMenuItem
impl StructuralPartialEq for StringMenuItem
Auto Trait Implementations§
impl Freeze for StringMenuItem
impl RefUnwindSafe for StringMenuItem
impl Send for StringMenuItem
impl Sync for StringMenuItem
impl Unpin for StringMenuItem
impl UnwindSafe for StringMenuItem
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
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>
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>
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