Skip to main content

MaterialMenu

Struct MaterialMenu 

Source
pub struct MaterialMenu { /* private fields */ }
Expand description

An M3 menu surface. Use MenuPopup to open it from a trigger.

Implementations§

Source§

impl MaterialMenu

Source

pub fn new(id: impl Into<ElementId>) -> Self

Source

pub fn style(self, style: MenuStyle) -> Self

Source

pub fn density(self, density: MenuDensity) -> Self

Item density: the kit’s baseline densities, and half those steps for Expressive items.

Source

pub fn item(self, item: MaterialMenuItem) -> Self

Append an item to the last group.

Source

pub fn items(self, items: impl IntoIterator<Item = MaterialMenuItem>) -> Self

Source

pub fn group(self, group: MenuGroup) -> Self

Source

pub fn width(self, width: f32) -> Self

Width in design px (default 200 baseline, 208 Expressive).

Source

pub fn elevated(self, elevated: bool) -> Self

Paint the menu’s level 2 shadow (default). A popup paints it on its revealing frame instead.

Source

pub fn track_focus(self, focus: &FocusHandle) -> Self

The handle the menu root tracks; arrow keys from it reach the items.

Source

pub fn on_dismiss( self, handler: impl Fn(&mut Window, &mut App) + 'static, ) -> Self

Escape inside the menu.

Source

pub fn on_activate( self, handler: impl Fn(&mut Window, &mut App) + 'static, ) -> Self

Runs after any enabled item (other than a sub-menu) is activated.

Source

pub fn on_collapse( self, handler: impl Fn(&mut Window, &mut App) + 'static, ) -> Self

Left inside the menu, e.g. to close it as a cascading sub-menu.

Source

pub fn natural_height(&self) -> f32

The menu’s natural height in design px.

Source

pub fn item_bottom(&self, index: usize) -> Option<f32>

The bottom of the item at flat index (its row without a divider below it), in design px from the menu’s top.

Source

pub fn item_top(&self, index: usize) -> Option<f32>

The top of the item at flat index (its row, with an Expressive row’s insets), in design px from the menu’s top.

Trait Implementations§

Source§

impl IntoElement for MaterialMenu

Source§

type Element = ViewElement<MaterialMenu>

The specific type of element into which the implementing type is converted. Useful for converting other types into elements automatically, like Strings
Source§

fn into_element(self) -> Self::Element

Convert self into a type that implements [Element].
Source§

fn into_any_element(self) -> AnyElement

Convert self into a dynamically-typed [AnyElement].
Source§

impl RenderOnce for MaterialMenu

Source§

fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement

Render this component into an element tree. Note that this method takes ownership of self, as compared to [Render::render()] method which takes a mutable reference.

Auto Trait Implementations§

Blanket Implementations§

§

impl<E> AnimationExt for E
where E: IntoElement + 'static,

§

fn with_animation( self, id: impl Into<ElementId>, animation: Animation, animator: impl Fn(Self, f32) -> Self + 'static, ) -> AnimationElement<Self>
where Self: Sized,

Render this component or element with an animation
§

fn with_animations( self, id: impl Into<ElementId>, animations: Vec<Animation>, animator: impl Fn(Self, usize, f32) -> Self + 'static, ) -> AnimationElement<Self>
where Self: Sized,

Render this component or element with a chain of animations
§

fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
where Self: Sized, T: SpringTarget, <T as SpringTarget>::Output: 'static,

Renders this component or element at the value produced by a spring. Read more
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,

Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> FluentBuilder for T
where T: IntoElement,

§

fn map<U>(self, f: impl FnOnce(Self) -> U) -> U
where Self: Sized,

Imperatively modify self with the given closure.
§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
where Self: Sized,

Conditionally modify self with the given closure.
§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self
where Self: Sized,

Conditionally modify self with the given closure.
§

fn when_some<T>( self, option: Option<T>, then: impl FnOnce(Self, T) -> Self, ) -> Self
where Self: Sized,

Conditionally unwrap and modify self with the given closure, if the given option is Some.
§

fn when_none<T>( self, option: &Option<T>, then: impl FnOnce(Self) -> Self, ) -> Self
where Self: Sized,

Conditionally unwrap and modify self with the given closure, if the given option is None.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<E> TestTextExt for E
where E: IntoElement,

§

fn test_text(self, text: impl Into<SharedString>) -> Self::Element

With test-support, records text each time the element paints. Otherwise returns the element it builds.
§

fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element

Like [Self::test_text] for an image’s alternative text, which stands in for what the element draws.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> View for T
where T: RenderOnce,

§

fn entity_id(&self) -> Option<EntityId>

This view’s identity, if it has one. A view typically holds the backing entity as a field and returns its [EntityId] here. Read more
§

fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement

Render this view into an element tree, consuming self.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more