Translating Mouse Hit X Offset to Caret Position
Conventionally, the user can select caret position (cp) by clicking either the trailing half of character "cp-1" or the leading half of character "cp". An application can implement the translation of mouse hit x offset to caret position as follows:
int iCharPos;
int iCaretPos;
int fTrailing;
ScriptXtoCP(iMouseX, cChars, cGlyphs, pwLogClust, psva, piAdvance, psa,
&iCharPos, &fTrailing);
iCaretPos = iCharPos + fTrailing;
For scripts that snap the caret to cluster boundaries, a call to ScriptXtoCP returns with fTrailing set to either 0 or the width of the cluster in code points.
Related topics
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for