feat: hide overlay when tap on the editor

This commit is contained in:
Lucas.Xu 2022-07-21 15:21:19 +08:00
parent e2f35dd5cc
commit e3e1d25494
2 changed files with 18 additions and 3 deletions

View File

@ -46,6 +46,13 @@ class _EditorNodeWidget extends StatelessWidget {
..onEnd = _onPanEnd;
},
),
TapGestureRecognizer:
GestureRecognizerFactoryWithHandlers<TapGestureRecognizer>(
() => TapGestureRecognizer(),
(recongizer) {
recongizer..onTap = _onTap;
},
)
},
child: SingleChildScrollView(
child: Column(
@ -66,8 +73,15 @@ class _EditorNodeWidget extends StatelessWidget {
);
}
void _onTap() {
editorState.panStartOffset = null;
editorState.panEndOffset = null;
editorState.updateSelection();
}
void _onPanStart(DragStartDetails details) {
editorState.panStartOffset = details.globalPosition;
editorState.updateSelection();
}
void _onPanUpdate(DragUpdateDetails details) {

View File

@ -56,6 +56,10 @@ class EditorState {
List<OverlayEntry> selectionOverlays = [];
void updateSelection() {
selectionOverlays
..forEach((element) => element.remove())
..clear();
final selectedNodes = _selectedNodes;
if (selectedNodes.isEmpty) {
return;
@ -63,9 +67,6 @@ class EditorState {
assert(panStartOffset != null && panEndOffset != null);
selectionOverlays
..forEach((element) => element.remove())
..clear();
for (final node in selectedNodes) {
final key = node.key;
if (key != null && key.currentState is Selectable) {