expandLastSelectionByBlock method
UserSelectionState
expandLastSelectionByBlock(
- AxisDirection direction, {
- required IntVector2 getNextCoordinateInCellsBlock(
- IntVector2 coordinate
- required int limit,
Expands last selection in a given AxisDirection by a block of cells.
TableUserSelectionModels are not expandable, HeaderUserSelectionModel are expandable only on the cross axis and CellUserSelectionModel is expandable in all directions.
See also:
TableShortcuts
andTableActions
where the shortcuts are mapped into actions that allow the user to expand the last selection
Implementation
UserSelectionState expandLastSelectionByBlock(
AxisDirection direction, {
required IntVector2 Function(IntVector2 coordinate)
getNextCoordinateInCellsBlock,
required int limit,
}) {
if (primarySelection is TableUserSelectionModel) {
return this;
}
if (primarySelection is HeaderUserSelectionModel) {
final selection = primarySelection as HeaderUserSelectionModel;
if (selection.axis != axisDirectionToAxis(direction)) {
return this;
}
final focus =
direction == AxisDirection.up || direction == AxisDirection.left
? 0
: limit;
return updateLastSelectionToHeaderSelection(
focus: focus,
axis: selection.axis,
);
}
final selection = primarySelection as CellUserSelectionModel;
final newFocus = getNextCoordinateInCellsBlock(selection.focus);
return updateLastSelectionToCellSelection(
focus: newFocus,
anchor: selection.anchor,
);
}