|
|
@@ -684,11 +684,12 @@ namespace Avalonia.Controls
|
|
|
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
|
|
{
|
|
|
var point = e.GetPosition(_presenter);
|
|
|
- var index = CaretIndex = _presenter.GetCaretIndex(point);
|
|
|
+ var index = _presenter.GetCaretIndex(point);
|
|
|
var text = Text;
|
|
|
|
|
|
- if (text != null && e.MouseButton == MouseButton.Left)
|
|
|
+ if (text != null && e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
|
|
|
{
|
|
|
+ CaretIndex = index;
|
|
|
switch (e.ClickCount)
|
|
|
{
|
|
|
case 1:
|
|
|
@@ -714,7 +715,8 @@ namespace Avalonia.Controls
|
|
|
|
|
|
protected override void OnPointerMoved(PointerEventArgs e)
|
|
|
{
|
|
|
- if (_presenter != null && e.Pointer.Captured == _presenter)
|
|
|
+ // selection should not change during pointer move if the user right clicks
|
|
|
+ if (_presenter != null && e.Pointer.Captured == _presenter && !e.GetCurrentPoint(this).Properties.IsRightButtonPressed)
|
|
|
{
|
|
|
var point = e.GetPosition(_presenter);
|
|
|
|
|
|
@@ -727,6 +729,22 @@ namespace Avalonia.Controls
|
|
|
{
|
|
|
if (_presenter != null && e.Pointer.Captured == _presenter)
|
|
|
{
|
|
|
+ if (e.InitialPressMouseButton == MouseButton.Right)
|
|
|
+ {
|
|
|
+ var point = e.GetPosition(_presenter);
|
|
|
+ var caretIndex = _presenter.GetCaretIndex(point);
|
|
|
+
|
|
|
+ // see if mouse clicked inside current selection
|
|
|
+ // if it did not, we change the selection to where the user clicked
|
|
|
+ var firstSelection = Math.Min(SelectionStart, SelectionEnd);
|
|
|
+ var lastSelection = Math.Max(SelectionStart, SelectionEnd);
|
|
|
+ var didClickInSelection = SelectionStart != SelectionEnd &&
|
|
|
+ caretIndex >= firstSelection && caretIndex <= lastSelection;
|
|
|
+ if (!didClickInSelection)
|
|
|
+ {
|
|
|
+ CaretIndex = SelectionEnd = SelectionStart = caretIndex;
|
|
|
+ }
|
|
|
+ }
|
|
|
e.Pointer.Capture(null);
|
|
|
}
|
|
|
}
|