Skip to main content

ContextMenu

Struct ContextMenu 

Source
pub struct ContextMenu<V: 'static, K: 'static = ()>(/* private fields */);
Expand description

A view’s menu: closed, or open with its rows and what choosing one does.

Implementations§

Source§

impl<V: 'static, K: PartialEq + 'static> ContextMenu<V, K>

Source

pub fn open( &mut self, key: K, place: Place, items: Vec<Item>, on_choose: impl Fn(&mut V, &[usize], &mut Window, &mut Context<'_, V>) + 'static, window: &mut Window, cx: &mut Context<'_, V>, )

Open items as the menu key, standing at place and taking the keyboard. A menu already open is replaced.

Source

pub fn toggle<F>( view: &mut V, slot: Slot<V, K>, key: K, place: Place, build: impl FnOnce(&mut V, &mut Window, &mut Context<'_, V>) -> (Vec<Item>, F), window: &mut Window, cx: &mut Context<'_, V>, )
where F: Fn(&mut V, &[usize], &mut Window, &mut Context<'_, V>) + 'static,

Open the menu key, or close it when it is the one up or the press that led here found it up — see Self::note_press. build makes the rows and what choosing one does, and runs only when the menu opens.

Source

pub fn note_press(&mut self, key: &K)

Note, from a trigger’s press, whether the menu key is on screen. The open card dismisses on that same press, so by click time the menu reads as closed, and Self::toggle would open it straight back without this.

Source

pub fn trigger<E: StatefulInteractiveElement>( el: E, slot: Slot<V, K>, key: K, cx: &Context<'_, V>, ) -> E

el, noting its presses for the menu key — see Self::note_press. Every trigger that calls Self::toggle needs it.

Source

pub fn key(&self) -> Option<&K>

Which menu is open. None while none is, or the last one is on its way out.

Source

pub fn is_open(&self) -> bool

Source

pub fn showing(&self, key: &K) -> bool

Whether the menu key is on screen, open or on its way out.

Source

pub fn point_at(&mut self, path: &[usize]) -> bool

Light the row at path, as the pointer would. Whether that moved the cursor.

Source

pub fn clear_cursor(&mut self)

Light no row.

Source

pub fn close(view: &mut V, slot: Slot<V, K>, cx: &mut Context<'_, V>)

Close the menu, leaving the focus where it is.

Source

pub fn card( &self, id: impl Into<SharedString>, slot: Slot<V, K>, window: &mut Window, cx: &mut Context<'_, V>, ) -> Option<Div>

The menu’s card while it is on screen, not yet placed: for a caller that sizes it before Self::place. id prefixes its rows’ element ids and debug selectors — see menu::card.

Source

pub fn place( &self, id: impl Into<SharedString>, card: impl IntoElement, ) -> AnyElement

Stand card where the menu opened. For every Place but Place::At, draw it as a child of the trigger.

Source

pub fn render( &self, id: impl Into<SharedString>, slot: Slot<V, K>, window: &mut Window, cx: &mut Context<'_, V>, ) -> Option<AnyElement>

The menu, placed, while it is on screen.

Source

pub fn render_for( &self, key: &K, id: impl Into<SharedString>, slot: Slot<V, K>, window: &mut Window, cx: &mut Context<'_, V>, ) -> Option<AnyElement>

Self::render for the menu key alone: what a trigger hangs beside itself.

Trait Implementations§

Source§

impl<V: 'static, K: 'static> Default for ContextMenu<V, K>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<V, K = ()> !RefUnwindSafe for ContextMenu<V, K>

§

impl<V, K = ()> !Send for ContextMenu<V, K>

§

impl<V, K = ()> !Sync for ContextMenu<V, K>

§

impl<V, K = ()> !UnwindSafe for ContextMenu<V, K>

§

impl<V, K> Forget for ContextMenu<V, K>

§

impl<V, K> Freeze for ContextMenu<V, K>
where Popup<Open<V, K>>: Freeze,

§

impl<V, K> Move for ContextMenu<V, K>

§

impl<V, K> Unpin for ContextMenu<V, K>
where Popup<Open<V, K>>: Unpin,

§

impl<V, K> UnsafeUnpin for ContextMenu<V, K>
where Popup<Open<V, K>>: UnsafeUnpin,

Blanket Implementations§

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

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

Source§

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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

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

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

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

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