pub struct ContextMenuRequest {
pub target: ContextMenuTarget,
pub selection: Option<ContextMenuSelection>,
/* private fields */
}Expand description
Lazy snapshot of the right-click context, captured at menu-open time.
Construction is O(1): the request holds shared (Arc) handles to the
grid’s row data, display order, and column metadata plus the normalized
selection bounds. No per-cell or per-row data is cloned when the menu
opens, so right-clicking a huge selection is instant.
The owned per-cell / per-row snapshots are materialized on demand:
clicked_cell/clicked_roware cheap (a single cell / row).for_each_selected_cell/for_each_selected_rowstream the selection without allocating a big intermediateVec— prefer these in background work (e.g. building an export).selected_cells/selected_rowscollect into aVecfor convenience; these clone O(cells)/O(rows x cols) owned data and should be called off the UI thread for large selections (seeGridState::spawn_background).
All indices are display indices (post sort/filter) unless prefixed with
source_.
For column-oriented targets (ColumnHeader, SortButton, or a
Selection::Column), the row accessors are empty — a column right-click is
column-oriented (clicked_row() is None), so the column’s values are
exposed through the cell accessors and full per-row snapshots are skipped.
The type is Send + Sync + 'static (it holds only Arcs and Copy
bounds), so a clone can be moved into a background task.
Fields§
§target: ContextMenuTarget§selection: Option<ContextMenuSelection>Implementations§
Source§impl ContextMenuRequest
impl ContextMenuRequest
Sourcepub fn clicked_cell(&self) -> Option<SelectedCellContext>
pub fn clicked_cell(&self) -> Option<SelectedCellContext>
The specific cell under the cursor when the menu opened, if the right-click landed on a data cell. Cheap (clones one cell).
Sourcepub fn clicked_row(&self) -> Option<SelectedRowContext>
pub fn clicked_row(&self) -> Option<SelectedRowContext>
The row under the cursor when the menu opened, if the right-click landed on a cell or row header. Cheap (clones one row).
Sourcepub fn selected_cell_count(&self) -> usize
pub fn selected_cell_count(&self) -> usize
Number of cells in the effective selection. O(1) — computed from the selection bounds without materializing anything.
Sourcepub fn selected_row_count(&self) -> usize
pub fn selected_row_count(&self) -> usize
Number of rows in the effective selection. 0 for column-oriented
targets. O(1).
Sourcepub fn is_column_oriented(&self) -> bool
pub fn is_column_oriented(&self) -> bool
Whether this request is column-oriented (a column-header/sort-button
right-click or a Selection::Column), in which case the row accessors
are empty.
Sourcepub fn for_each_selected_cell(&self, f: impl FnMut(SelectedCellContext))
pub fn for_each_selected_cell(&self, f: impl FnMut(SelectedCellContext))
Stream every selected cell without allocating an intermediate Vec.
Prefer this in background work.
Sourcepub fn for_each_selected_row(&self, f: impl FnMut(SelectedRowContext))
pub fn for_each_selected_row(&self, f: impl FnMut(SelectedRowContext))
Stream every selected row without allocating an intermediate Vec.
Yields nothing for column-oriented targets. Prefer this in background
work.
Sourcepub fn selected_cells(&self) -> Vec<SelectedCellContext>
pub fn selected_cells(&self) -> Vec<SelectedCellContext>
All selected cells in the effective selection, materialized into a
Vec. Clones O(cells) owned data — call off the UI thread for large
selections.
Sourcepub fn selected_rows(&self) -> Vec<SelectedRowContext>
pub fn selected_rows(&self) -> Vec<SelectedRowContext>
All selected rows in the effective selection, materialized into a
Vec (empty for column-oriented targets). Clones O(rows x cols) owned
data — call off the UI thread for large selections.
Trait Implementations§
Source§impl Clone for ContextMenuRequest
impl Clone for ContextMenuRequest
Source§fn clone(&self) -> ContextMenuRequest
fn clone(&self) -> ContextMenuRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ContextMenuRequest
impl RefUnwindSafe for ContextMenuRequest
impl Send for ContextMenuRequest
impl Sync for ContextMenuRequest
impl Unpin for ContextMenuRequest
impl UnsafeUnpin for ContextMenuRequest
impl UnwindSafe for ContextMenuRequest
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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 more