Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

ScriptUI -> Radio Buttons broken in v2020?

Return to Member Forum

  • Author
    Posts
    • #1220282

      Greetings!

      I had bought a long time ago the Lynda.com courses that David did and fond memories made me come here.
      I subscribe here years later, having an issue that cost me the better part of a day, and having remembered David’s website.

      It appears that Radio Buttons don’t work anymore in ID 2020/ExtendScript/ScriptUI.

      Have a peek at this short video that explains it: https://youtu.be/rcgLwjzR9qc

      Or try this sample code:

      var dialog = new Window(“dialog”);
      dialog.text = “Dialog”;
      dialog.orientation = “column”;
      dialog.alignChildren = [“center”,”top”];
      dialog.spacing = 10;
      dialog.margins = 16;

      var grp = dialog.add(“group”, undefined, {name: “grp”});
      grp.orientation = “row”;
      grp.alignChildren = [“left”,”center”];
      grp.addEventListener (“click”, clickety());

      function clickety(){var error = “no one comes here”;};

      var r1 = grp.add(“radiobutton”, undefined, undefined, {name: “r1”});
      r1.text = “We Quit”;

      var r2 = grp.add(“radiobutton”, undefined, undefined, {name: “r2”});
      r2.text = “No more radio buttons for you”;

      dialog.show();

      I’m sorely hoping someone can help me out of this issue without having to resort to going down the CEP rabbit hole!!!

      Cheers from Vancouver,

      Antoine

    • #14323363
      Jeremy Howard
      Participant

      Hey Antoine,

      I actually just helped another user with this same issue earlier tonight. Rather than using the “addEventListener” just use “onClick”. Something like this should do:

      radio3.onClick = function(){
      //– Do things here
      }

      That being said, if you prefer to use the “addEventListener” method for some reason, just make sure that you are applying the event listener to the proper element. Your line “var grp = dialog.add(“group”, undefined, {name: “grp”});” states that the “grp” variable is the group that the radio buttons will be nested within but then you go on to add your event listener to the “grp” variable with this line: “grp.addEventListener (“click”, clickety());”

      That’s why you are getting functionality when you click the area around the radio buttons. When you do that, you are clicking on the group which is what actually has the eventListener added to it!

      To make it work with that method, you would want something like: “r1.addEventListener (“click”, clickety());”

      Make sense?

    • #14323362

      Well, that’s embarrassing easy to solve.
      I owe you two lattes, I guess! :-)
      I’ve been found!

      Cheers again,

      Antoine

Viewing 2 reply threads
  • You must be logged in to reply to this topic.
Forum Ads