Skip to main content

SelectionPolicy

Trait SelectionPolicy 

Source
pub trait SelectionPolicy<R: GridRow>: 'static {
    // Required methods
    fn is_selectable(&self, line: &SelectableLine<'_, R>) -> bool;
    fn line_scope(
        &self,
        context: &LineScopeContext<'_, R>,
    ) -> Option<ScopedSelection<R::Key>>;
}
Expand description

Which lines can be selected, and what a command over a line acts on: a group caption, or a tree row with children.

is_selectable is asked per line by Cmd/Ctrl+A, Shift ranges and drags; line_scope once per command, for its target: the focused line for Enter and Cmd/Ctrl+C, the menu’s target, a double-clicked row. Both run on the UI thread.

The default is FocusCaptions: tree rows are data rows and take the selection, as in AG Grid’s tree data and DevExpress TreeList. Built in too, FocusBranches: tree rows with children take the focus but not the selection, and a command over one acts on its subtree’s leaves. Another plausible one: selectable captions whose selection takes their group’s rows (AG Grid’s groupSelectsChildren).

Required Methods§

Source

fn is_selectable(&self, line: &SelectableLine<'_, R>) -> bool

Returns true if line can be selected. A selectable caption adds its group’s live rows to the selection; a selectable row itself.

Source

fn line_scope( &self, context: &LineScopeContext<'_, R>, ) -> Option<ScopedSelection<R::Key>>

The scope of a command whose target is context.line(); None: the command acts on scoped_selection().

Implementors§