pub enum PopupMenuItem {
Separator,
Label(SharedString),
Item {
icon: Option<Icon>,
label: SharedString,
disabled: bool,
is_link: bool,
action: Option<Box<dyn Action>>,
handler: Option<Rc<dyn Fn(&ClickEvent, &mut Window, &mut App)>>,
},
ElementItem {
icon: Option<Icon>,
disabled: bool,
action: Option<Box<dyn Action>>,
render: Box<dyn Fn(&mut Window, &mut App) -> AnyElement + 'static>,
handler: Option<Rc<dyn Fn(&ClickEvent, &mut Window, &mut App)>>,
},
Submenu {
icon: Option<Icon>,
label: SharedString,
disabled: bool,
menu: Entity<PopupMenu>,
},
}Expand description
An menu item in a popup menu.
Variants§
Separator
A menu separator item.
Label(SharedString)
A non-interactive label item.
Item
A standard menu item.
Fields
label: SharedStringElementItem
A menu item with custom element render.
Fields
A submenu item that opens another popup menu.
NOTE: This is only supported when the parent menu is not scrollable.
Implementations§
Source§impl PopupMenuItem
impl PopupMenuItem
Sourcepub fn new(label: impl Into<SharedString>) -> Self
pub fn new(label: impl Into<SharedString>) -> Self
Create a new menu item with the given label.
Create a new submenu item that opens another popup menu.
Sourcepub fn label(label: impl Into<SharedString>) -> Self
pub fn label(label: impl Into<SharedString>) -> Self
Creates a label menu item.
Sourcepub fn icon(self, icon: impl Into<Icon>) -> Self
pub fn icon(self, icon: impl Into<Icon>) -> Self
Set the icon for the menu item.
Only works for PopupMenuItem::Item, PopupMenuItem::ElementItem and PopupMenuItem::Submenu.
Sourcepub fn action(self, action: Box<dyn Action>) -> Self
pub fn action(self, action: Box<dyn Action>) -> Self
Set the action for the menu item.
Only works for PopupMenuItem::Item and PopupMenuItem::ElementItem.
Sourcepub fn disabled(self, disabled: bool) -> Self
pub fn disabled(self, disabled: bool) -> Self
Set the disabled state for the menu item.
Only works for PopupMenuItem::Item, PopupMenuItem::ElementItem and PopupMenuItem::Submenu.
Sourcepub fn checked(self, checked: bool) -> Self
pub fn checked(self, checked: bool) -> Self
Set checked state for the menu item by adding or removing check icon.
If true, will set the icon to check icon, otherwise remove the icon.
Sourcepub fn on_click<F>(self, handler: F) -> Self
pub fn on_click<F>(self, handler: F) -> Self
Add a click handler for the menu item.
Only works for PopupMenuItem::Item and PopupMenuItem::ElementItem.
Trait Implementations§
Source§impl FluentBuilder for PopupMenuItem
impl FluentBuilder for PopupMenuItem
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
Auto Trait Implementations§
impl Freeze for PopupMenuItem
impl !RefUnwindSafe for PopupMenuItem
impl !Send for PopupMenuItem
impl !Sync for PopupMenuItem
impl Unpin for PopupMenuItem
impl !UnwindSafe for PopupMenuItem
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> 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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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