Skip to content
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 method for TextBox #9540

Open
rampaa opened this issue Nov 25, 2022 · 1 comment
Open

GetCharacterIndexFromPoint method for TextBox #9540

rampaa opened this issue Nov 25, 2022 · 1 comment

Comments

@rampaa
Copy link

rampaa commented Nov 25, 2022

Is your feature request related to a problem? Please describe.
I want to get the index of the character from the TextBox that is closest to cursor position but I'm not sure if there's a straightforward way of achieving this.

Describe the solution you'd like
WPF TextBox has a method called GetCharacterIndexFromPoint, a method equivalent to that would let me achieve my goal.

@Gillibald
Copy link
Contributor

That should not be too complicated to add. The hard work is already done by the underlying TextLayout.

https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Base/Media/TextFormatting/TextLayout.cs#L283 for example

TextLayout is exposed to the TextBox via the _textPresenter

Contributions are welcome 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants