Skip to main content
Inspiring
January 10, 2019
Question

Make edittext active when radiobutton clicked

  • January 10, 2019
  • 1 reply
  • 1102 views

I have a complex panel, and am trying to jump straight to an edittext when a radiobutton is clicked.

Greatly simplified:

     box.groupButton.onClick = function ( ) { box.groupEdittext.active = true };

box.groupEdittext reports as active when tested in the long version of the above function, but neither shows as having the focus nor has the cursor placed in it.

I've also tried:

     box.groupButton.addEventListener ( 'click', function ( ) { box.groupEdittext.active = true } );

with the same (non) effect.

Elsewhere:

     box.groupEdittext1.onActivate = function ( ) { box.groupEdittext2.active = true };

(which is the closest to an onClick event as one can get with edittext) works as expected (albeit not a lot of use), putting the focus on box.groupEdittext2and placing the cursor in it.

Changing the radiobutton to a checkbox effects no change in behaviour.

Any ideas how to achieve this simple jump very much welcomed, or is it impractical/impossible?  Or am I too stupid to see the blindingly simple error/solution?

This topic has been closed for replies.

1 reply

Legend
January 10, 2019

Grimbaldus 

      box.groupButton.onClick = function ( ) { box.groupEdittext.active = true };

In CS6, everything works great. In CC (2018), as always, nothing works.
Use this method

var d = new Window("dialog")

var r1 = d.add("radiobutton", undefined, " R1");         

var r2 = d.add("radiobutton", undefined, " R2");         

var dummy = d.add("statictext", undefined, "");         

var t1 = d.add("edittext", undefined, " 11111111111111");         

r1.onClick = function() { dummy.active = true; t1.active = true;  }

d.show()

Inspiring
January 10, 2019

r-bin​, thanks, but the existing full code of the box.groupButton.onClick function already makes a statictext active.  So no joy.

PS: I should have said, CC2019 (20.0.1) on Win10.  I'll check tomorrow (UK) on Mojave and revert if that is any different.

Kukurykus
Legend
January 11, 2019

Duh!

I said it was a complex panel, with a lot of code.  In testing this morning, I observed that a statictext box was being changed under certain infrequently occurring circumstances.  Detailed investigation then revealed two variable names which differed only in the classic "Zero/Oh".

Fixed that and the a/m problem vanished.

Thanks to all for thinking through the issue, and especially to r-bin​.


Me too, so like yestarday I couldn't understand what that guy wants: Detect clipping path when pasting imagine