pub struct Menu { /* private fields */ }Expand description
A list of commands, opened from a trigger.
Implementations§
Source§impl Menu
impl Menu
pub fn new( ident: impl Into<Ident>, _window: &mut Window, cx: &mut Context<'_, Self>, ) -> Self
Sourcepub fn trigger(self, label: impl Into<SharedString>) -> Self
pub fn trigger(self, label: impl Into<SharedString>) -> Self
The label of the control that opens the menu.
pub fn trigger_icon(self, glyph: Icon) -> Self
Sourcepub fn trigger_name(self, name: impl Into<SharedString>) -> Self
pub fn trigger_name(self, name: impl Into<SharedString>) -> Self
What the trigger is called when it has no label of its own, for a menu opened from a glyph such as the arrow of a split button.
pub fn set_trigger_name( &mut self, name: impl Into<SharedString>, cx: &mut Context<'_, Self>, )
Sourcepub fn trigger_variant(self, variant: ButtonVariant) -> Self
pub fn trigger_variant(self, variant: ButtonVariant) -> Self
How the trigger is painted, for a menu that sits inside another control and has to look like part of it.
Sourcepub fn trigger_join(self, join: ButtonJoin) -> Self
pub fn trigger_join(self, join: ButtonJoin) -> Self
Where the trigger sits in a joined run of buttons.
Sourcepub fn set_trigger_style(
&mut self,
variant: ButtonVariant,
size: ControlSize,
cx: &mut Context<'_, Self>,
)
pub fn set_trigger_style( &mut self, variant: ButtonVariant, size: ControlSize, cx: &mut Context<'_, Self>, )
Repaints the trigger for an owner whose own paint is decided after the menu is built.
pub fn items(self, items: impl IntoIterator<Item = MenuItem>) -> Self
pub fn placement(self, placement: Placement) -> Self
Sourcepub fn offered(&self) -> &[MenuItem]
pub fn offered(&self) -> &[MenuItem]
The rows the menu currently offers, so an owner that maintains them can tell whether a replacement would change anything.
Sourcepub fn set_items(&mut self, items: Vec<MenuItem>, cx: &mut Context<'_, Self>)
pub fn set_items(&mut self, items: Vec<MenuItem>, cx: &mut Context<'_, Self>)
Replaces the items from the host side, dropping a cursor that pointed into what is no longer offered.
pub fn is_open(&self) -> bool
pub fn open(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Opens the menu with the submenu carrying id already expanded, and
reports whether such a submenu exists.
Sourcepub fn close(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
pub fn close(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Closes the menu and every submenu under it, and gives the keyboard back to the trigger.
pub fn dismiss(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
pub fn toggle(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Trait Implementations§
impl EventEmitter<MenuEvent> for Menu
Source§impl Focusable for Menu
impl Focusable for Menu
Source§fn focus_handle(&self, _cx: &App) -> FocusHandle
fn focus_handle(&self, _cx: &App) -> FocusHandle
Auto Trait Implementations§
impl !RefUnwindSafe for Menu
impl !UnwindSafe for Menu
impl Freeze for Menu
impl Send for Menu
impl Sync for Menu
impl Unpin for Menu
impl UnsafeUnpin for Menu
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