expandLastSelection method
UserSelectionState
expandLastSelection(
- AxisDirection direction, {
- required IntVector2 getNextCoordinate(
- IntVector2 coordinate
Expands last selection in a given AxisDirection.
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 expandLastSelection(
AxisDirection direction, {
required IntVector2 Function(IntVector2 coordinate) getNextCoordinate,
}) {
if (primarySelection is TableUserSelectionModel) {
return this;
}
if (primarySelection is HeaderUserSelectionModel) {
final selection = primarySelection as HeaderUserSelectionModel;
if (selection.axis != axisDirectionToAxis(direction)) {
return this;
}
final newFocus = getNextCoordinate(selection.focusCoordinate);
return updateLastSelectionToHeaderSelection(
focus: selection.axis == Axis.horizontal ? newFocus.dx : newFocus.dy,
axis: selection.axis,
);
}
final selection = primarySelection as CellUserSelectionModel;
final newFocus = getNextCoordinate(selection.focus);
return updateLastSelectionToCellSelection(
focus: newFocus,
anchor: selection.anchor,
);
}