mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: cursor doesn't blink when opening selection menu (#1622)
* fix: cursor doesn't blink when opening selection menu * chore: fix dart lint
This commit is contained in:
parent
b09f37e025
commit
5c1b084789
@ -111,7 +111,7 @@ class SelectionMenu implements SelectionMenuService {
|
|||||||
|
|
||||||
Overlay.of(context)?.insert(_selectionMenuEntry!);
|
Overlay.of(context)?.insert(_selectionMenuEntry!);
|
||||||
|
|
||||||
editorState.service.keyboardService?.disable();
|
editorState.service.keyboardService?.disable(showCursor: true);
|
||||||
editorState.service.scrollService?.disable();
|
editorState.service.scrollService?.disable();
|
||||||
selectionService.currentSelection.addListener(_onSelectionChange);
|
selectionService.currentSelection.addListener(_onSelectionChange);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ abstract class AppFlowyKeyboardService {
|
|||||||
/// you can disable the keyboard service of flowy_editor.
|
/// you can disable the keyboard service of flowy_editor.
|
||||||
/// But you need to call the `enable` function to restore after exiting
|
/// But you need to call the `enable` function to restore after exiting
|
||||||
/// your custom component, otherwise the keyboard service will fails.
|
/// your custom component, otherwise the keyboard service will fails.
|
||||||
void disable();
|
void disable({bool showCursor = false});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Process keyboard events
|
/// Process keyboard events
|
||||||
@ -62,6 +62,7 @@ class _AppFlowyKeyboardState extends State<AppFlowyKeyboard>
|
|||||||
final FocusNode _focusNode = FocusNode(debugLabel: 'flowy_keyboard_service');
|
final FocusNode _focusNode = FocusNode(debugLabel: 'flowy_keyboard_service');
|
||||||
|
|
||||||
bool isFocus = true;
|
bool isFocus = true;
|
||||||
|
bool showCursor = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<ShortcutEvent> get shortcutEvents => widget.shortcutEvents;
|
List<ShortcutEvent> get shortcutEvents => widget.shortcutEvents;
|
||||||
@ -101,8 +102,9 @@ class _AppFlowyKeyboardState extends State<AppFlowyKeyboard>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void disable() {
|
void disable({bool showCursor = false}) {
|
||||||
isFocus = false;
|
isFocus = false;
|
||||||
|
this.showCursor = showCursor;
|
||||||
_focusNode.unfocus();
|
_focusNode.unfocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,8 +139,10 @@ class _AppFlowyKeyboardState extends State<AppFlowyKeyboard>
|
|||||||
void _onFocusChange(bool value) {
|
void _onFocusChange(bool value) {
|
||||||
Log.keyboard.debug('on keyboard event focus change $value');
|
Log.keyboard.debug('on keyboard event focus change $value');
|
||||||
isFocus = value;
|
isFocus = value;
|
||||||
if (!value) {
|
if (!value && !showCursor) {
|
||||||
widget.editorState.service.selectionService.clearCursor();
|
widget.editorState.service.selectionService.clearCursor();
|
||||||
|
} else {
|
||||||
|
showCursor = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import 'package:flutter/services.dart';
|
|||||||
import 'emoji_picker.dart';
|
import 'emoji_picker.dart';
|
||||||
|
|
||||||
SelectionMenuItem emojiMenuItem = SelectionMenuItem(
|
SelectionMenuItem emojiMenuItem = SelectionMenuItem(
|
||||||
name: () => 'emoji',
|
name: () => 'Emoji',
|
||||||
icon: (editorState, onSelected) => Icon(
|
icon: (editorState, onSelected) => Icon(
|
||||||
Icons.emoji_emotions_outlined,
|
Icons.emoji_emotions_outlined,
|
||||||
color: onSelected
|
color: onSelected
|
||||||
|
Loading…
Reference in New Issue
Block a user