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.
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 Forget for PopupMenuItem
impl Freeze for PopupMenuItemwhere
&'static str: Freeze,
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<BoxShadow>: Freeze,
*const ArcInner<Vec<(String, u32)>> is !null: Freeze,
PhantomData<ArcInner<Vec<(String, u32)>>>: Freeze,
*const ArcInner<Vec<String>> is !null: Freeze,
PhantomData<ArcInner<Vec<String>>>: Freeze,
*const ArcInner<[u8]> is !null: Freeze,
PhantomData<ArcInner<[u8]>>: Freeze,
*const dyn Action is !null: Freeze,
PhantomData<dyn Action>: Freeze,
*const RcInner<dyn Fn(&ClickEvent, &mut Window, &mut App)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&ClickEvent, &mut Window, &mut App)>>: Freeze,
*const dyn Fn(&mut Window, &mut App) -> AnyElement is !null: Freeze,
PhantomData<dyn Fn(&mut Window, &mut App) -> AnyElement>: Freeze,
NonZero<u32>: Freeze,
*const (): Freeze,
*const ArcInner<RwLock<RawRwLock, EntityRefCounts>> is !null: Freeze,
PhantomData<fn(PopupMenu) -> PopupMenu>: Freeze,
impl Move for PopupMenuItem
impl Unpin for PopupMenuItemwhere
&'static str: Unpin,
Arc<str>: Unpin,
*const u8 is !null: Unpin,
Arc<Vec<(String, u32)>>: Unpin,
Arc<Vec<String>>: Unpin,
Arc<[u8]>: Unpin,
Box<dyn Action>: Unpin,
Rc<dyn Fn(&ClickEvent, &mut Window, &mut App)>: Unpin,
Box<dyn Fn(&mut Window, &mut App) -> AnyElement>: Unpin,
NonZero<u32>: Unpin,
*const (): Unpin,
*const ArcInner<RwLock<RawRwLock, EntityRefCounts>> is !null: Unpin,
impl UnsafeUnpin for PopupMenuItemwhere
&'static str: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<BoxShadow>: UnsafeUnpin,
*const ArcInner<Vec<(String, u32)>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Vec<(String, u32)>>>: UnsafeUnpin,
*const ArcInner<Vec<String>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Vec<String>>>: UnsafeUnpin,
*const ArcInner<[u8]> is !null: UnsafeUnpin,
PhantomData<ArcInner<[u8]>>: UnsafeUnpin,
*const dyn Action is !null: UnsafeUnpin,
PhantomData<dyn Action>: UnsafeUnpin,
*const RcInner<dyn Fn(&ClickEvent, &mut Window, &mut App)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&ClickEvent, &mut Window, &mut App)>>: UnsafeUnpin,
*const dyn Fn(&mut Window, &mut App) -> AnyElement is !null: UnsafeUnpin,
PhantomData<dyn Fn(&mut Window, &mut App) -> AnyElement>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
*const (): UnsafeUnpin,
*const ArcInner<RwLock<RawRwLock, EntityRefCounts>> is !null: UnsafeUnpin,
PhantomData<fn(PopupMenu) -> PopupMenu>: UnsafeUnpin,
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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