Browse Source

remove textbox holding handler in text selection handle (#19186)

release/11.3.3
Emmanuel Hansen 1 year ago
committed by Julien Lebosquain
parent
commit
4ca154ed31
  1. 15
      src/Avalonia.Controls/Primitives/TextSelectionCanvas.cs

15
src/Avalonia.Controls/Primitives/TextSelectionCanvas.cs

@ -70,6 +70,10 @@ namespace Avalonia.Controls.Primitives
_caretHandle.PointerReleased += Handle_PointerReleased; _caretHandle.PointerReleased += Handle_PointerReleased;
_endHandle.PointerReleased += Handle_PointerReleased; _endHandle.PointerReleased += Handle_PointerReleased;
_startHandle.Holding += Caret_Holding;
_caretHandle.Holding += Caret_Holding;
_endHandle.Holding += Caret_Holding;
IsVisible = ShowHandles; IsVisible = ShowHandles;
ClipToBounds = false; ClipToBounds = false;
@ -214,7 +218,12 @@ namespace Avalonia.Controls.Primitives
public void MoveHandlesToSelection() public void MoveHandlesToSelection()
{ {
if (_presenter == null || _textBox == null || _startHandle.IsDragging || _endHandle.IsDragging) if (_presenter == null
|| _textBox == null
|| _startHandle.IsDragging
|| _endHandle.IsDragging
|| _textBox.ContextFlyout?.IsOpen == true
|| _textBox.ContextMenu?.IsOpen == true)
{ {
return; return;
} }
@ -268,7 +277,6 @@ namespace Avalonia.Controls.Primitives
_textBox.RemoveHandler(TextBox.TextChangingEvent, TextChanged); _textBox.RemoveHandler(TextBox.TextChangingEvent, TextChanged);
_textBox.RemoveHandler(KeyDownEvent, TextBoxKeyDown); _textBox.RemoveHandler(KeyDownEvent, TextBoxKeyDown);
_textBox.RemoveHandler(PointerReleasedEvent, TextBoxPointerReleased); _textBox.RemoveHandler(PointerReleasedEvent, TextBoxPointerReleased);
_textBox.RemoveHandler(Gestures.HoldingEvent, TextBoxHolding);
_textBox.PropertyChanged -= TextBoxPropertyChanged; _textBox.PropertyChanged -= TextBoxPropertyChanged;
_textBox.EffectiveViewportChanged -= TextBoxEffectiveViewportChanged; _textBox.EffectiveViewportChanged -= TextBoxEffectiveViewportChanged;
@ -287,7 +295,6 @@ namespace Avalonia.Controls.Primitives
_textBox.AddHandler(TextBox.TextChangingEvent, TextChanged, handledEventsToo: true); _textBox.AddHandler(TextBox.TextChangingEvent, TextChanged, handledEventsToo: true);
_textBox.AddHandler(KeyDownEvent, TextBoxKeyDown, handledEventsToo: true); _textBox.AddHandler(KeyDownEvent, TextBoxKeyDown, handledEventsToo: true);
_textBox.AddHandler(PointerReleasedEvent, TextBoxPointerReleased, handledEventsToo: true); _textBox.AddHandler(PointerReleasedEvent, TextBoxPointerReleased, handledEventsToo: true);
_textBox.AddHandler(Gestures.HoldingEvent, TextBoxHolding, handledEventsToo: true);
_textBox.PropertyChanged += TextBoxPropertyChanged; _textBox.PropertyChanged += TextBoxPropertyChanged;
_textBox.EffectiveViewportChanged += TextBoxEffectiveViewportChanged; _textBox.EffectiveViewportChanged += TextBoxEffectiveViewportChanged;
@ -310,7 +317,7 @@ namespace Avalonia.Controls.Primitives
} }
} }
private void TextBoxHolding(object? sender, HoldingRoutedEventArgs e) private void Caret_Holding(object? sender, HoldingRoutedEventArgs e)
{ {
if (ShowContextMenu()) if (ShowContextMenu())
e.Handled = true; e.Handled = true;

Loading…
Cancel
Save