pub enum PopupMenuItem {
Separator,
Label(SharedString),
Item {
icon: Option<Icon>,
label: SharedString,
disabled: bool,
checked: 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,
checked: 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.
NOTE: If check_side is Side::Left, the icon will replace with a check 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 !RefUnwindSafe for PopupMenuItem
impl !Send for PopupMenuItem
impl !Sync for PopupMenuItem
impl !UnwindSafe for PopupMenuItem
impl Freeze for PopupMenuItem
impl Unpin for PopupMenuItem
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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