Browse Source

fix skia formatted text impl hit testing.

pull/3213/head
Dan Walmsley 7 years ago
parent
commit
075aeecebf
  1. 28
      src/Skia/Avalonia.Skia/FormattedTextImpl.cs

28
src/Skia/Avalonia.Skia/FormattedTextImpl.cs

@ -102,12 +102,17 @@ namespace Avalonia.Skia
AvaloniaFormattedTextLine line = default;
int i = 0;
while(_skiaLines[i].Top < y && i < _skiaLines.Count)
foreach(var currentLine in _skiaLines)
{
line = _skiaLines[i++];
}
if(currentLine.Top <= y)
{
line = currentLine;
}
else
{
break;
}
}
if (!line.Equals(default))
{
@ -135,12 +140,15 @@ namespace Avalonia.Skia
line.Length : (line.Length - 1);
}
return new TextHitTestResult
if (y < line.Top + line.Height)
{
IsInside = false,
TextPosition = line.Start + offset,
IsTrailing = Text.Length == (line.Start + offset + 1)
};
return new TextHitTestResult
{
IsInside = false,
TextPosition = line.Start + offset,
IsTrailing = Text.Length == (line.Start + offset + 1)
};
}
}
bool end = point.X > _bounds.Width || point.Y > _lines.Sum(l => l.Height);

Loading…
Cancel
Save