From 9af2284d677173fd69765185d35460ba2be6c424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ku=C4=8Dera?= <10546952+miloush@users.noreply.github.com> Date: Fri, 9 Jun 2023 10:40:31 +0100 Subject: [PATCH] Use alignment for GetLineIndexFromPoint (#7730) Co-authored-by: miloush --- .../MS/Internal/documents/TextBoxView.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/TextBoxView.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/TextBoxView.cs index 7e9b41040..735ac71b4 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/TextBoxView.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/TextBoxView.cs @@ -1680,10 +1680,13 @@ private int GetLineIndexFromPoint(Point point, bool snapToText) } else { - if (!snapToText && - (point.X < 0 || point.X >= record.Width)) + if (!snapToText) { - index = -1; + double alignmentOffset = GetContentOffset(record.Width, CalculatedTextAlignment); + if (point.X < alignmentOffset || point.X >= record.Width + alignmentOffset) + { + index = -1; + } } break; } -- GitLab