Copy link to clipboard
Copied
For a multi-line edit box control, once the control gains input focus, within the control or on the screeis there a way to get the current caret (text cursor) positionn? I’m not looking to get the cursor position in the text flow, but rather the cursor's position within the control or on the screen.
The kTextEditBoxWidgetBoss includes an ICursorRegion interface, but I’m not sure how to use it. From the functions provided by that interface, it doesn't seem to offer what I need.
Has anyone had experience with this? Any help would be greatly appreciated.
Copy link to clipboard
Copied
ICursorRegion is used by the cursor mgr to get the mouse cursor icon, e.g. pointer, i-beam, for a region before it asks again. So is your intention to influence the cursor icon?
We already both mentioned that event handler overloading. Instead of a specialization of the kTextEditBoxWidgetBoss boss class (as it is a native backed control) I suggested you wrap it in some parent widget where you do the overload. Did that not work?
To change the cursor icon I'd overload the ICursorRegion in a similar way, on a wrapping parent widget. Overloading directly on the native widget is asking for trouble .
Copy link to clipboard
Copied
Re-reading, you even mentioned the caret. So ICursorRegion is the wrong cursor.
I'd use IEditBoxAttributes::GetStartOfSelection() and GetEndOfSelection(). Unfortunately that will give you char counters / text offsets rather than coordinates.
A decade ago I'd have looked how far DrawStringUtils::PMMeasureString will match the native control, but given modern times, and that you're in a multi line scenario, you would waste your time.
Again, try to get a hold on your control's HWND and use OS calls. Or create a twin native control somewhere outside the screen and query that.