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();
if (delegate.selectionEnabled && !_isPositionSelected(details)) {
final _platform = Theme.of(_state.context).platform;
if (isAppleOS(_platform)) {
switch (details.kind) {
case PointerDeviceKind.mouse:
case PointerDeviceKind.stylus:
case PointerDeviceKind.invertedStylus:
// Precise devices should place the cursor at a precise position.
// If `Shift` key is pressed then
// extend current selection instead.
if (isShiftClick(details.kind)) {
try {
if (delegate.selectionEnabled && !_isPositionSelected(details)) {
final _platform = Theme.of(_state.context).platform;
if (isAppleOS(_platform)) {
switch (details.kind) {
case PointerDeviceKind.mouse:
case PointerDeviceKind.stylus:
case PointerDeviceKind.invertedStylus:
// Precise devices should place the cursor at a precise position.
// If `Shift` key is pressed then
// 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!
..extendSelection(details.globalPosition,
cause: SelectionChangedCause.tap)
..selectWordEdge(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!
..selectWordEdge(SelectionChangedCause.tap)
..onSelectionCompleted();
break;
break;
}
} else {
renderEditor!
..selectPosition(cause: SelectionChangedCause.tap)
..onSelectionCompleted();
}
} else {
renderEditor!
..selectPosition(cause: SelectionChangedCause.tap)
..onSelectionCompleted();
}
} finally {
_state._requestKeyboard();
}
_state._requestKeyboard();
}
@override

Loading…
Cancel
Save