in GUI Development by
Hi Gents,

 I'm working on a virtual keyboard, with a TextEditor field. In my Init{} (I also tried a idlesignal InitSlot{}) I specify:

TextEditor.caretIndex = TextEditor.String.length;

But the caret keeps blinking at position 0. However, if I type text the text is entered in where expected... at the end.
Any thoughts?

1 Answer

0 votes

Hello Mike,

I have just tried your application case and it seems to work. In the Init method I perform following code, nothing else is necessary:

TextEditor.caretIndex = TextEditor.String.length;

The interesting question thus, what is the difference between your and mine test? I assume, you are using the Text Editor template, right? Which Embedded Wizard version are you using?

Best regards

Paul Banach


Hi Paul,

 I'm on 9.30. 

I'm using the TextEditor template. 



When I enter the dialog the caret is on the left in position 0:


But when I start to type (the letter m here) the caret appears where expected at the end:

Oh, I was doing an idlesingal into that InitSlot{} as a result of tinkering. That was part of the issue. TextEditor.caretIndex = TextEditor.String.length; needs to be in Init{}. But that sets the caret position to whatever the default text is defined as with TextEditor. And not the new value passed in.

TextEditor's OnSetString{} doesnt seem to update the caret position.

I've implemented a proxy string Property to get this done:


Hello Mike,

it seems you have found the right solution. In fact, the example from my preceding answer used the length of the string stored already in TextEditor. In turn, your approach adapts in the TextEditor the caret position according to the just assigned string. Consequently, the code you added to PPS_Keyboard.String property could also be implemented within the TextEditor. You can try following:

1. In TextEditor component open the OnSetString method.

2. Scroll to the end of the method.

3. At the end of the onset method append following row:

caretIndex = value.length;

This updates the caretIndex each time the TextEditor receives a new string. Invoking updateCaret is not necessary in this case, because it will be invoked internally by Text view each time new string is assigned to the view.

4. The OnSetString method within the PPS_Keyboard component can be simplified now. Just relay the assigned string to the TextEditor:

// The value doesn't change - nothing to do.
if ( pure String == value )

// Remember the property's new value.
pure String = value;

// ... and finally update the Text Editor to show the string.
TextEditor.String = value;

I tried out the above approach and it works. I hope it does also in your case. But finally, it is up to you which approach you prefer to use :o)

Best regards

Paul Banach

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint