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>
impl<V: 'static, K: PartialEq + 'static> ContextMenu<V, K>
Sourcepub 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>,
)
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.
Sourcepub 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>,
)
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>, )
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.
Sourcepub fn note_press(&mut self, key: &K)
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.
Sourcepub fn trigger<E: StatefulInteractiveElement>(
el: E,
slot: Slot<V, K>,
key: K,
cx: &Context<'_, V>,
) -> E
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.
Sourcepub fn key(&self) -> Option<&K>
pub fn key(&self) -> Option<&K>
Which menu is open. None while none is, or the last one is on its way
out.
pub fn is_open(&self) -> bool
Sourcepub fn showing(&self, key: &K) -> bool
pub fn showing(&self, key: &K) -> bool
Whether the menu key is on screen, open or on its way out.
Sourcepub fn point_at(&mut self, path: &[usize]) -> bool
pub fn point_at(&mut self, path: &[usize]) -> bool
Light the row at path, as the pointer would. Whether that moved the
cursor.
Sourcepub fn clear_cursor(&mut self)
pub fn clear_cursor(&mut self)
Light no row.
Sourcepub fn close(view: &mut V, slot: Slot<V, K>, cx: &mut Context<'_, V>)
pub fn close(view: &mut V, slot: Slot<V, K>, cx: &mut Context<'_, V>)
Close the menu, leaving the focus where it is.
Sourcepub fn card(
&self,
id: impl Into<SharedString>,
slot: Slot<V, K>,
window: &mut Window,
cx: &mut Context<'_, V>,
) -> Option<Div>
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.
Sourcepub fn place(
&self,
id: impl Into<SharedString>,
card: impl IntoElement,
) -> AnyElement
pub fn place( &self, id: impl Into<SharedString>, card: impl IntoElement, ) -> AnyElement
Sourcepub fn render(
&self,
id: impl Into<SharedString>,
slot: Slot<V, K>,
window: &mut Window,
cx: &mut Context<'_, V>,
) -> Option<AnyElement>
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.
Sourcepub fn render_for(
&self,
key: &K,
id: impl Into<SharedString>,
slot: Slot<V, K>,
window: &mut Window,
cx: &mut Context<'_, V>,
) -> Option<AnyElement>
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§
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> Freeze for ContextMenu<V, K>
impl<V, K> Unpin for ContextMenu<V, K>
impl<V, K> UnsafeUnpin for ContextMenu<V, K>where
Popup<Open<V, K>>: UnsafeUnpin,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().