dispatchSelectionEvent method
- SelectionEvent event
override
Handles the SelectionEvent sent to this object.
The subclasses need to update their selections or delegate the SelectionEvents to their subtrees.
The events are subclasses of SelectionEvent. Check
SelectionEvent.type to determine what kinds of event are dispatched to
this handler and handle them accordingly.
See also:
- SelectionEventType, which contains all of the possible types.
Implementation
@override
SelectionResult dispatchSelectionEvent(SelectionEvent event) {
final bool selectionWillBeInProgress = event is! ClearSelectionEvent;
if (!_selectionInProgress && selectionWillBeInProgress) {
// Sort the selectable every time a selection start.
selectables.sort(compareOrder);
}
_selectionInProgress = selectionWillBeInProgress;
_isHandlingSelectionEvent = true;
late SelectionResult result;
switch (event.type) {
case SelectionEventType.startEdgeUpdate:
case SelectionEventType.endEdgeUpdate:
_extendSelectionInProgress = false;
result = handleSelectionEdgeUpdate(event as SelectionEdgeUpdateEvent);
case SelectionEventType.clear:
_extendSelectionInProgress = false;
result = handleClearSelection(event as ClearSelectionEvent);
case SelectionEventType.selectAll:
_extendSelectionInProgress = false;
result = handleSelectAll(event as SelectAllSelectionEvent);
case SelectionEventType.selectWord:
_extendSelectionInProgress = false;
result = handleSelectWord(event as SelectWordSelectionEvent);
case SelectionEventType.selectParagraph:
_extendSelectionInProgress = false;
result = handleSelectParagraph(event as SelectParagraphSelectionEvent);
case SelectionEventType.granularlyExtendSelection:
_extendSelectionInProgress = true;
result = handleGranularlyExtendSelection(event as GranularlyExtendSelectionEvent);
case SelectionEventType.directionallyExtendSelection:
_extendSelectionInProgress = true;
result = handleDirectionallyExtendSelection(event as DirectionallyExtendSelectionEvent);
}
_isHandlingSelectionEvent = false;
_updateSelectionGeometry();
return result;
}