pub struct SubMenuItem {
pub label: String,
pub shortcut: Option<KeyboardShortcut>,
pub enabled: bool,
pub separator_after: bool,
pub callback: Option<Box<dyn Fn() + Send + Sync>>,
pub children: Vec<SubMenuItem>,
}Expand description
A single submenu item with customization options.
Represents an entry inside a dropdown menu, with optional keyboard shortcut, enabled/disabled state, separator, callback, and nested children.
Fields§
§label: StringThe visible label for this submenu item.
shortcut: Option<KeyboardShortcut>Optional keyboard shortcut that triggers this item.
enabled: boolWhether the item can be interacted with.
separator_after: boolIf true, draws a separator line after this item.
callback: Option<Box<dyn Fn() + Send + Sync>>Optional callback executed when the item is activated.
children: Vec<SubMenuItem>Optional nested submenu items.
Implementations§
Source§impl SubMenuItem
impl SubMenuItem
Sourcepub fn with_shortcut(self, shortcut: KeyboardShortcut) -> Self
pub fn with_shortcut(self, shortcut: KeyboardShortcut) -> Self
Assign a keyboard shortcut to this item.
Sourcepub fn with_callback(self, callback: Box<dyn Fn() + Send + Sync>) -> Self
pub fn with_callback(self, callback: Box<dyn Fn() + Send + Sync>) -> Self
Set the callback executed when this item is activated.
Sourcepub fn with_separator(self) -> Self
pub fn with_separator(self) -> Self
Draw a separator line after this item.
Sourcepub fn add_child(self, child: SubMenuItem) -> Self
pub fn add_child(self, child: SubMenuItem) -> Self
Append a child item to this submenu.
Sourcepub fn with_children(self, children: Vec<SubMenuItem>) -> Self
pub fn with_children(self, children: Vec<SubMenuItem>) -> Self
Replace the children of this submenu.
Trait Implementations§
Source§impl Clone for SubMenuItem
impl Clone for SubMenuItem
Auto Trait Implementations§
impl Freeze for SubMenuItem
impl !RefUnwindSafe for SubMenuItem
impl Send for SubMenuItem
impl Sync for SubMenuItem
impl Unpin for SubMenuItem
impl !UnwindSafe for SubMenuItem
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.