Request keyboard focus when no child is found (#713)

pull/723/head
Arshak Aghakaryan 3 years ago committed by GitHub
parent e1cd184336
commit ef0355d814
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 69
      lib/src/widgets/editor.dart

@ -591,44 +591,47 @@ class _QuillEditorSelectionGestureDetectorBuilder
editor!.hideToolbar(); editor!.hideToolbar();
if (delegate.selectionEnabled && !_isPositionSelected(details)) { try {
final _platform = Theme.of(_state.context).platform; if (delegate.selectionEnabled && !_isPositionSelected(details)) {
if (isAppleOS(_platform)) { final _platform = Theme.of(_state.context).platform;
switch (details.kind) { if (isAppleOS(_platform)) {
case PointerDeviceKind.mouse: switch (details.kind) {
case PointerDeviceKind.stylus: case PointerDeviceKind.mouse:
case PointerDeviceKind.invertedStylus: case PointerDeviceKind.stylus:
// Precise devices should place the cursor at a precise position. case PointerDeviceKind.invertedStylus:
// If `Shift` key is pressed then // Precise devices should place the cursor at a precise position.
// extend current selection instead. // If `Shift` key is pressed then
if (isShiftClick(details.kind)) { // extend current selection instead.
if (isShiftClick(details.kind)) {
renderEditor!
..extendSelection(details.globalPosition,
cause: SelectionChangedCause.tap)
..onSelectionCompleted();
} else {
renderEditor!
..selectPosition(cause: SelectionChangedCause.tap)
..onSelectionCompleted();
}
break;
case PointerDeviceKind.touch:
case PointerDeviceKind.unknown:
// On macOS/iOS/iPadOS a touch tap places the cursor at the edge
// of the word.
renderEditor! renderEditor!
..extendSelection(details.globalPosition, ..selectWordEdge(SelectionChangedCause.tap)
cause: SelectionChangedCause.tap)
..onSelectionCompleted(); ..onSelectionCompleted();
} else { break;
renderEditor! }
..selectPosition(cause: SelectionChangedCause.tap) } else {
..onSelectionCompleted(); renderEditor!
} ..selectPosition(cause: SelectionChangedCause.tap)
..onSelectionCompleted();
break;
case PointerDeviceKind.touch:
case PointerDeviceKind.unknown:
// On macOS/iOS/iPadOS a touch tap places the cursor at the edge
// of the word.
renderEditor!
..selectWordEdge(SelectionChangedCause.tap)
..onSelectionCompleted();
break;
} }
} else {
renderEditor!
..selectPosition(cause: SelectionChangedCause.tap)
..onSelectionCompleted();
} }
} finally {
_state._requestKeyboard();
} }
_state._requestKeyboard();
} }
@override @override

Loading…
Cancel
Save