Browse Source
Merge pull request #2074 from Sorien/edit-box-selection
make sure pointer is always inside presenter
text-input
Steven Kirk
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
4 additions and
1 deletions
-
src/Avalonia.Controls/TextBox.cs
-
src/Skia/Avalonia.Skia/FormattedTextImpl.cs
|
|
|
@ -14,6 +14,7 @@ using Avalonia.Interactivity; |
|
|
|
using Avalonia.Media; |
|
|
|
using Avalonia.Metadata; |
|
|
|
using Avalonia.Data; |
|
|
|
using Avalonia.Utilities; |
|
|
|
|
|
|
|
namespace Avalonia.Controls |
|
|
|
{ |
|
|
|
@ -655,6 +656,8 @@ namespace Avalonia.Controls |
|
|
|
if (_presenter != null && e.Device.Captured == _presenter) |
|
|
|
{ |
|
|
|
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)); |
|
|
|
CaretIndex = SelectionEnd = _presenter.GetCaretIndex(point); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -121,7 +121,7 @@ namespace Avalonia.Skia |
|
|
|
|
|
|
|
int offset = 0; |
|
|
|
|
|
|
|
if (point.X >= (rects[line.Start].X + line.Width) / 2 && line.Length > 0) |
|
|
|
if (point.X >= (rects[line.Start].X + line.Width) && line.Length > 0) |
|
|
|
{ |
|
|
|
offset = line.TextLength > line.Length ? |
|
|
|
line.Length : (line.Length - 1); |
|
|
|
|