Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

c++ plugin,is there a way to get the current text cursor position for editbox control?

Explorer ,
Apr 21, 2025 Apr 21, 2025

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.

TOPICS
SDK
113
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 22, 2025 Apr 22, 2025

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 .

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 22, 2025 Apr 22, 2025
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines