Skip to main content

MenuPopup

Struct MenuPopup 

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

A trigger that opens a MaterialMenu in Kit’s popover overlay.

open is controlled: Kit’s popover reports pointer toggles, outside clicks and Escape through on_open_change, and an activated item closes the menu the same way (unless Self::close_on_activate is off). Keyboard activation of the trigger itself is the caller’s (e.g. its button’s click handler).

A cascading sub-menu (Self::submenu) opens beside the item that owns it, on the side away from the popup’s anchor edge, with the same reveal motion. Right on a sub-menu item activates it (the caller opens the sub-menu, which takes focus); Left or Escape inside the sub-menu reports false through Self::on_submenu_change and returns focus to the parent menu.

Implementations§

Source§

impl MenuPopup

Source

pub fn new( id: impl Into<ElementId>, trigger: impl IntoElement, menu: MaterialMenu, ) -> Self

Source

pub fn close_on_activate(self, close: bool) -> Self

Close the menu when an item (other than a sub-menu) is activated (default). Off, the menu stays open, e.g. to toggle several items.

Source

pub fn submenu(self, index: usize, menu: MaterialMenu, open: bool) -> Self

A cascading sub-menu for the main menu’s item at flat index (counting across groups), shown while open.

Source

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

Left or Escape inside the open sub-menu reports false.

Source

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

Source

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

Source

pub fn anchor(self, anchor: Anchor) -> Self

The popup’s own anchor corner (Kit’s convention; default top-left, below the trigger). LeftCenter and RightCenter place the menu beside the trigger, to its right or left, with their tops aligned (M3’s “right start” and “left start” placements).

Trait Implementations§

Source§

impl IntoElement for MenuPopup

Source§

type Element = ViewElement<MenuPopup>

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 MenuPopup

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