fix: The cursor will not disappear after clicking in an area outside the editor.

This commit is contained in:
Lucas.Xu 2022-08-29 12:10:57 +08:00
parent dd9cac9c1d
commit 42866e1057
2 changed files with 16 additions and 2 deletions

View File

@ -129,6 +129,10 @@ class _AppFlowyKeyboardState extends State<AppFlowyKeyboard>
void _onFocusChange(bool value) {
Log.keyboard.debug('on keyboard event focus change $value');
isFocus = value;
if (!value) {
widget.editorState.service.selectionService.clearCursor();
}
}
KeyEventResult _onKey(FocusNode node, RawKeyEvent event) {

View File

@ -57,6 +57,9 @@ abstract class AppFlowySelectionService {
/// Clears the selection area, cursor area and the popup list area.
void clearSelection();
/// Clears the cursor area.
void clearCursor();
/// Returns the [Node]s in [Selection].
List<Node> getNodesInSelection(Selection selection);
@ -205,16 +208,23 @@ class _AppFlowySelectionState extends State<AppFlowySelection>
currentSelectedNodes = [];
currentSelection.value = null;
clearCursor();
// clear selection areas
_selectionAreas
..forEach((overlay) => overlay.remove())
..clear();
// clear cursor areas
// hide toolbar
editorState.service.toolbarService?.hide();
}
@override
void clearCursor() {
// clear cursor areas
_cursorAreas
..forEach((overlay) => overlay.remove())
..clear();
// hide toolbar
editorState.service.toolbarService?.hide();
}
@override