pub struct Menu { /* private fields */ }Expand description
Positions a Material menu against a caller-owned, keyboard-focusable trigger. Pointer and keyboard activation use the same Base popover focus lifecycle.
Implementations§
Source§impl Menu
impl Menu
Sourcepub fn new(
id: impl Into<ElementId>,
trigger: impl IntoElement,
items: impl IntoIterator<Item = MenuItem>,
) -> Menu
pub fn new( id: impl Into<ElementId>, trigger: impl IntoElement, items: impl IntoIterator<Item = MenuItem>, ) -> Menu
Creates a menu anchored to trigger with eagerly constructed items.
Sourcepub fn new_with<I>(
id: impl Into<ElementId>,
trigger: impl IntoElement,
build: impl FnOnce(&mut Window, &mut App) -> I + 'static,
) -> Menuwhere
I: IntoIterator<Item = MenuItem>,
pub fn new_with<I>(
id: impl Into<ElementId>,
trigger: impl IntoElement,
build: impl FnOnce(&mut Window, &mut App) -> I + 'static,
) -> Menuwhere
I: IntoIterator<Item = MenuItem>,
Creates a menu whose items are built lazily only while the menu is open.
Sourcepub fn disabled(self, disabled: bool) -> Menu
pub fn disabled(self, disabled: bool) -> Menu
Disables menu activation while continuing to render the trigger element.
Sourcepub fn context(self) -> Menu
pub fn context(self) -> Menu
Opens on secondary click at the pointer location (viewport-clamped), or
anchored to the trigger on Shift+F10 / ContextMenu, without hijacking
the trigger’s own Enter or Space activation.
Sourcepub fn anchor(self, anchor: Anchor) -> Menu
pub fn anchor(self, anchor: Anchor) -> Menu
Sets the anchor corner used to align the popup against its trigger (default Anchor::TopLeft).
Sourcepub fn offset(self, offset: Pixels) -> Menu
pub fn offset(self, offset: Pixels) -> Menu
Sets the outward gap between the trigger and popup.
Sourcepub fn position(self, position: Point<Pixels>) -> Menu
pub fn position(self, position: Point<Pixels>) -> Menu
Anchors the popup at a window-local point. It remains clamped to the viewport.
Sourcepub fn color(self, color: MenuColor) -> Menu
pub fn color(self, color: MenuColor) -> Menu
Applies a semantic color preset to the menu and its submenus.
Sourcepub fn appearance(self, appearance: MenuSurfaceStyle) -> Menu
pub fn appearance(self, appearance: MenuSurfaceStyle) -> Menu
Applies overrides to this popup’s surface.
Sourcepub fn content<E>(self, build: impl Fn() -> E + 'static) -> Menuwhere
E: IntoElement,
pub fn content<E>(self, build: impl Fn() -> E + 'static) -> Menuwhere
E: IntoElement,
Renders arbitrary content before the menu rows. Use a repeatable factory for content that also needs to appear during exit.
Sourcepub fn track_scroll(self, scroll: &ScrollHandle) -> Menu
pub fn track_scroll(self, scroll: &ScrollHandle) -> Menu
Tracks the popup’s scrolling through a caller-owned handle.
Sourcepub fn composed(
id: impl Into<ElementId>,
items: impl IntoIterator<Item = MenuItem>,
trigger: impl FnOnce(bool, Rc<dyn Fn(&mut Window, &mut App)>) -> AnyElement + 'static,
) -> Menu
pub fn composed( id: impl Into<ElementId>, items: impl IntoIterator<Item = MenuItem>, trigger: impl FnOnce(bool, Rc<dyn Fn(&mut Window, &mut App)>) -> AnyElement + 'static, ) -> Menu
Builds a trigger from the displayed open value and its activation callback.
Keep the trigger focusable and use the supplied callback for a custom accessibility action. The menu owns pointer and keyboard activation.
Trait Implementations§
Source§impl IntoElement for Menu
impl IntoElement for Menu
Source§type Element = ViewElement<Menu>
type Element = ViewElement<Menu>
Source§fn into_element(self) -> <Menu as IntoElement>::Element
fn into_element(self) -> <Menu as IntoElement>::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for Menu
impl RenderOnce for Menu
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl !RefUnwindSafe for Menu
impl !Send for Menu
impl !Sync for Menu
impl !UnwindSafe for Menu
impl Forget for Menu
impl Freeze for Menu
impl Move for Menu
impl Unpin for Menu
impl UnsafeUnpin for Menu
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>
fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
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> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
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,
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 moreSource§impl<T> MaterialElementExt for Twhere
T: IntoElement,
impl<T> MaterialElementExt for Twhere
T: IntoElement,
Source§fn badge_label(self, text: impl Into<SharedString>) -> Badge
fn badge_label(self, text: impl Into<SharedString>) -> Badge
Badge to this element’s upper trailing edge.Source§fn badge_count(self, count: usize, maximum: usize) -> Badge
fn badge_count(self, count: usize, maximum: usize) -> Badge
Badge to this element’s upper trailing edge.Source§fn tooltip(
self,
id: impl Into<ElementId>,
text: impl Into<SharedString>,
) -> Tooltip
fn tooltip( self, id: impl Into<ElementId>, text: impl Into<SharedString>, ) -> Tooltip
Tooltip.Menu.Menu
whose items are built lazily only while the menu is open.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<E> TestTextExt for Ewhere
E: IntoElement,
impl<E> TestTextExt for Ewhere
E: IntoElement,
Source§fn test_text(self, text: impl Into<SharedString>) -> Self::Element
fn test_text(self, text: impl Into<SharedString>) -> Self::Element
test-support, records text each time the element paints.
Otherwise returns the element it builds.Source§fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element
fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element
Self::test_text for an image’s alternative text, which
stands in for what the element draws.