Skip to main content
Participant
April 14, 2020
Question

ScriptUI - edittext cursor resets when other edittext text are changed

  • April 14, 2020
  • 1 reply
  • 523 views

I have a problem with ScriptUI. Consider the folliwing example:

 

var dialog = new Window("dialog");
var txt1 = dialog.add("edittext", undefined, "0");
var txt2 = dialog.add("edittext", undefined, "0");
txt2.onChanging= function () {
  txt1.text = txt1.text + '0';
}
dialog.show();
 
While I type on txt2 I basically change the text in txt1 as well.
This strangely reset txt2 cursor at the beginning of the text. 
Is there a way to keep the cursor where it is?
 
I tried to change sliders, or other things while I type, but for some reason this is the only exception.
 
Thank you in advance 
 
This topic has been closed for replies.

1 reply

Kukurykus
Legend
April 14, 2020

Maybe highlight active entry in txt2, that'll be reseted each time you type something in:

 

txt2.active = false
txt1.text = txt1.text + '0';
txt2.active = true
Participant
April 15, 2020

Thanks for your answer.

But no, I also tried that. That causes txt2 text to be fully selected after each keypress. So basically if you try to type '42' what you would actually see in the edittext is 2.

Kukurykus
Legend
April 15, 2020

Try some (modified) configuration from this thread: UI set Caret position in editText control