Open
Description
openedon Jun 11, 2024
Background and motivation
In my app I need to get the character index from the mouse position. Even though I don't need the capabilities of a TextBox
, because TextBlock
does not have a method like GetCharacterIndexFromPoint, I need to use the TextBox control instead. The issue is my app creates lots of TextBoxes (which could have been TextBlocks if a TextBlock supported the aforementioned method) and a TextBox is more resource hungry than a TextBlock. So I'd like to avoid paying the price of a TextBox unnecessarily.
API Proposal
public int GetCharacterIndexFromPoint (System.Windows.Point point, bool snapToText);
API Usage
TextBlock textBlock = new();
int characterPosition = textBlock.GetCharacterIndexFromPoint(Mouse.GetPosition(textBlock), false);
Alternative Designs
No response
Risks
No response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment