Browse Source

Merge pull request #5115 from MarchingCube/fix-textbox-pointermove-crashes

Fix TextBox crashing when PointerMoved gets called
pull/5154/head
Dariusz Komosiński 5 years ago
committed by GitHub
parent
commit
3a13f59eff
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/Avalonia.Controls/TextBox.cs

5
src/Avalonia.Controls/TextBox.cs

@ -867,7 +867,10 @@ namespace Avalonia.Controls
{
var point = e.GetPosition(_presenter);
point = new Point(MathUtilities.Clamp(point.X, 0, _presenter.Bounds.Width - 1), MathUtilities.Clamp(point.Y, 0, _presenter.Bounds.Height - 1));
point = new Point(
MathUtilities.Clamp(point.X, 0, Math.Max(_presenter.Bounds.Width - 1, 0)),
MathUtilities.Clamp(point.Y, 0, Math.Max(_presenter.Bounds.Height - 1, 0)));
CaretIndex = SelectionEnd = _presenter.GetCaretIndex(point);
}
}

Loading…
Cancel
Save