-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GetCharacterIndexFromPoint does not work as intended if HorizontalContentAlignment is set to Center #7651
Comments
Hi,@rampaa. I encountered errors when unzipping your zip file. Could you provide a new zip file that can reproduce the problem? |
The workaround itself creates some other problems but it's better than not being able to lookup stuff when the text is centered
This comment was marked as outdated.
This comment was marked as outdated.
OK found it, the important part is that In that case wpf/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/TextBoxView.cs Lines 1642 to 1646 in f5be928
and the whole character finding is cancelled. wpf/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/TextBoxView.cs Lines 612 to 614 in f5be928
So a workaround is to use I think the fix should be in |
@dipeshmsft will the fix be backported to .NET 6? |
@rampaa - We'll need to discuss with shiproom if this can be backported to .NET 6/7. |
@pchaurasia14 thanks for your reply! I've developed an application that makes extensive use of GetCharacterIndexFromPoint so this bug is a real headache for me and for my user base. Would really appreciate a .NET 6 backport. |
Description
If the HorizontalContentAlignment of a TextBox is set to "Center" (or to "Right"), GetCharacterIndexFromPoint does not return the correct character index corresponding to a given point and instead returns -1.
Reproduction Steps
See the following demo:
GetCharacterIndexFromPointBugDemo.zip
Expected behavior
GetCharacterIndexFromPoint should return the correct character index from a given point even if the HorizontalContentAlignment is set to Center.
Actual behavior
GetCharacterIndexFromPoint returns -1 if HorizontalContentAlignment is set to Center/Right
Regression?
No response
Known Workarounds
No response
Impact
No response
Configuration
.NET 6/7
Windows 10 x64
Other information
No response
The text was updated successfully, but these errors were encountered: