Fix: make mouse right click to open context menu (#1976)

pull/1979/head v9.5.5
n7484443 9 months ago committed by GitHub
parent f766bf055e
commit eb60e27f37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      lib/src/widgets/others/delegate.dart

@ -85,6 +85,7 @@ class EditorTextSelectionGestureDetectorBuilder {
/// will return true if current [onTapDown] event is triggered by a touch or /// will return true if current [onTapDown] event is triggered by a touch or
/// a stylus. /// a stylus.
bool shouldShowSelectionToolbar = true; bool shouldShowSelectionToolbar = true;
bool requiresAdditionalActionForToolbar = false;
bool detectWordBoundary = true; bool detectWordBoundary = true;
@ -122,6 +123,7 @@ class EditorTextSelectionGestureDetectorBuilder {
.mouse || // Enable word selection by mouse double tap .mouse || // Enable word selection by mouse double tap
kind == PointerDeviceKind.touch || kind == PointerDeviceKind.touch ||
kind == PointerDeviceKind.stylus; kind == PointerDeviceKind.stylus;
requiresAdditionalActionForToolbar = kind == PointerDeviceKind.mouse;
} }
/// Handler for [EditorTextSelectionGestureDetector.onForcePressStart]. /// Handler for [EditorTextSelectionGestureDetector.onForcePressStart].
@ -167,7 +169,7 @@ class EditorTextSelectionGestureDetectorBuilder {
null, null,
SelectionChangedCause.forcePress, SelectionChangedCause.forcePress,
); );
if (shouldShowSelectionToolbar) { if (shouldShowSelectionToolbar && !requiresAdditionalActionForToolbar) {
editor!.showToolbar(); editor!.showToolbar();
} }
} }
@ -257,7 +259,7 @@ class EditorTextSelectionGestureDetectorBuilder {
/// which triggers this callback. /// which triggers this callback.
@protected @protected
void onSingleLongTapEnd(LongPressEndDetails details) { void onSingleLongTapEnd(LongPressEndDetails details) {
if (shouldShowSelectionToolbar) { if (shouldShowSelectionToolbar && !requiresAdditionalActionForToolbar) {
editor!.showToolbar(); editor!.showToolbar();
} }
} }
@ -282,7 +284,7 @@ class EditorTextSelectionGestureDetectorBuilder {
// have focus, selection hasn't been set when the toolbars // have focus, selection hasn't been set when the toolbars
// get added // get added
SchedulerBinding.instance.addPostFrameCallback((_) { SchedulerBinding.instance.addPostFrameCallback((_) {
if (shouldShowSelectionToolbar) { if (shouldShowSelectionToolbar && !requiresAdditionalActionForToolbar) {
editor!.showToolbar(); editor!.showToolbar();
} }
}); });
@ -334,7 +336,8 @@ class EditorTextSelectionGestureDetectorBuilder {
renderEditor!.handleDragEnd(details); renderEditor!.handleDragEnd(details);
if (isDesktop(supportWeb: true) && if (isDesktop(supportWeb: true) &&
delegate.selectionEnabled && delegate.selectionEnabled &&
shouldShowSelectionToolbar) { shouldShowSelectionToolbar &&
!requiresAdditionalActionForToolbar) {
// added to show selection copy/paste toolbar after drag to select // added to show selection copy/paste toolbar after drag to select
editor!.showToolbar(); editor!.showToolbar();
} }

Loading…
Cancel
Save