Unverified Commit 2c477b18 authored by Renzo Olivares's avatar Renzo Olivares Committed by GitHub

SelectableRegion onSelectionChange should be called when the selection changes (#134215)

This change makes sure to call `onSelectionChange` in all cases when selection might change including:
* Dragging selection handles
* Mouse drag to select
* Keyboard actions
* Long press drag to select
parent c7665ff8
...@@ -502,6 +502,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe ...@@ -502,6 +502,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe
case 2: case 2:
_selectWordAt(offset: details.globalPosition); _selectWordAt(offset: details.globalPosition);
} }
_updateSelectedContentIfNeeded();
} }
void _handleMouseDragStart(TapDragStartDetails details) { void _handleMouseDragStart(TapDragStartDetails details) {
...@@ -509,6 +510,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe ...@@ -509,6 +510,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe
case 1: case 1:
_selectStartTo(offset: details.globalPosition); _selectStartTo(offset: details.globalPosition);
} }
_updateSelectedContentIfNeeded();
} }
void _handleMouseDragUpdate(TapDragUpdateDetails details) { void _handleMouseDragUpdate(TapDragUpdateDetails details) {
...@@ -518,6 +520,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe ...@@ -518,6 +520,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe
case 2: case 2:
_selectEndTo(offset: details.globalPosition, continuous: true, textGranularity: TextGranularity.word); _selectEndTo(offset: details.globalPosition, continuous: true, textGranularity: TextGranularity.word);
} }
_updateSelectedContentIfNeeded();
} }
void _handleMouseDragEnd(TapDragEndDetails details) { void _handleMouseDragEnd(TapDragEndDetails details) {
...@@ -543,6 +546,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe ...@@ -543,6 +546,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe
void _handleTouchLongPressMoveUpdate(LongPressMoveUpdateDetails details) { void _handleTouchLongPressMoveUpdate(LongPressMoveUpdateDetails details) {
_selectEndTo(offset: details.globalPosition, textGranularity: TextGranularity.word); _selectEndTo(offset: details.globalPosition, textGranularity: TextGranularity.word);
_updateSelectedContentIfNeeded();
} }
void _handleTouchLongPressEnd(LongPressEndDetails details) { void _handleTouchLongPressEnd(LongPressEndDetails details) {
...@@ -717,6 +721,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe ...@@ -717,6 +721,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe
details.globalPosition, details.globalPosition,
_selectionDelegate.value.startSelectionPoint!, _selectionDelegate.value.startSelectionPoint!,
)); ));
_updateSelectedContentIfNeeded();
} }
void _handleSelectionStartHandleDragUpdate(DragUpdateDetails details) { void _handleSelectionStartHandleDragUpdate(DragUpdateDetails details) {
...@@ -730,6 +735,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe ...@@ -730,6 +735,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe
details.globalPosition, details.globalPosition,
_selectionDelegate.value.startSelectionPoint!, _selectionDelegate.value.startSelectionPoint!,
)); ));
_updateSelectedContentIfNeeded();
} }
void _handleSelectionEndHandleDragStart(DragStartDetails details) { void _handleSelectionEndHandleDragStart(DragStartDetails details) {
...@@ -742,6 +748,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe ...@@ -742,6 +748,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe
details.globalPosition, details.globalPosition,
_selectionDelegate.value.endSelectionPoint!, _selectionDelegate.value.endSelectionPoint!,
)); ));
_updateSelectedContentIfNeeded();
} }
void _handleSelectionEndHandleDragUpdate(DragUpdateDetails details) { void _handleSelectionEndHandleDragUpdate(DragUpdateDetails details) {
...@@ -755,6 +762,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe ...@@ -755,6 +762,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe
details.globalPosition, details.globalPosition,
_selectionDelegate.value.endSelectionPoint!, _selectionDelegate.value.endSelectionPoint!,
)); ));
_updateSelectedContentIfNeeded();
} }
MagnifierInfo _buildInfoForMagnifier(Offset globalGesturePosition, SelectionPoint selectionPoint) { MagnifierInfo _buildInfoForMagnifier(Offset globalGesturePosition, SelectionPoint selectionPoint) {
...@@ -1067,6 +1075,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe ...@@ -1067,6 +1075,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe
granularity: granularity, granularity: granularity,
), ),
); );
_updateSelectedContentIfNeeded();
} }
double? _directionalHorizontalBaseline; double? _directionalHorizontalBaseline;
...@@ -1088,6 +1097,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe ...@@ -1088,6 +1097,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe
dx: globalSelectionPointOffset.dx, dx: globalSelectionPointOffset.dx,
), ),
); );
_updateSelectedContentIfNeeded();
} }
// [TextSelectionDelegate] overrides. // [TextSelectionDelegate] overrides.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment