EditTextWidget: how to get current cusor position?

I’m trying to build a small code editor for simple instructions. The EditTextWidget is located inside a KeyboardWidget to intercept the return/enter key. This should trigger some actions like keyword check and increasing the memory address count. This works pretty well as long as code is appended at the end. But when I insert code into the text, I don’t know how to check for the current position of the cursor.

Is there an (hopefully) easy way to get the current cursor position inside the EditTextWidget?

I think that a possible workaround could be using a “WidgetMessage: tm-edit-text-operation”, but I’ve heard this only works with toolbar buttons and not for plain EditText.

I would also like to know if there is a way to achieve this.

In my opinion there isn’t any easy solution for this.
You have to catch any input and each cursor move, calculating the cursor position by yourself.

A any or all keyboard-code would help, actually the key-parameter for the Keyboard-widget is really long :wink:

Edited: for better readability

1 Like

I wonder how the CodeMirror plugin does it