2 Replies Latest reply on Jan 23, 2016 8:28 AM by winterm

    Dialog with radiobuttons

    winterm Level 5

      Honorable experts,


      I'm on Win7 64-bit, CS6 (ID

      Scripting skills - somewhere under the "Very Basic" level


      Now trying to adopt to my needs a dialog with radiobuttons, as in Peter Kahrel's Script UI v2-2, pdf page 17:

      var w = new Window ("dialog");
      var radio_group = w.add ("panel");
      radio_group.alignChildren = "left";
      radio_group.add ("radiobutton", undefined, "InDesign");
      radio_group.add ("radiobutton", undefined, "PDF");
      radio_group.add ("radiobutton", undefined, "IDML");
      radio_group.add ("radiobutton", undefined, "Text");
      w.add ("button", undefined, "OK");
      // set dialog defaults
      radio_group.children[0].value = true;
      function selected_rbutton (rbuttons)
      for (var i = 0; i < rbuttons.children.length; i++)
      if (rbuttons.children[i].value == true)
      return rbuttons.children[i].text;
      if (w.show () == 1)
      alert ("You picked " + selected_rbutton (radio_group))


      My version is intended to work on selected text (with Text tool). And here comes the problem.

      After selecting text with Ctrl+A, or Shift+End, or Ctrl+Shift+End -and then- hitting KB shortcut assigned to the script I usually "loose" mouse pointer. It's still here, but turns to be invisible over the whole InDesign window. "Usually" means approx. 5-6 of 10 times... Escaping script window and hitting script shortcut again always works - in next try mouse pointer stays visible. Until you select another portion of text...

      If text was selected with the mouse -or- script is invoked by double-clicking it's name in Scripts palette, everything's fine, always. Also works fine with any other kind of selection.

      Changing KB shortcut has no effect.

      Replacing a mouse has no effect. Microsoft (wired) and Logitech (wireless) optical mice tested.


      on a fully up-to-date system (Windows 10 Pro N, version 1511, build 10586.63 x64 / InDesign CC 2015.2, build x64) it works - there's no mouse pointer disappearing.

      Have no possibility to test on any other configuration right now.

      Could someone confirm this mouse related volatility on Win7/CS6, or is it somewhat unique to my system?


      And another question:

      Is it possible to enable here cycling through radiobuttons with an arrow keys, like it works in this Marc Autret's script?


      It would let me to live with the 1st problem unsolved... Keyboard-based workflow is preferable anyway.


      Here's is my modified version so far. However, it acts the same way as described above.

      w=new Window("dialog", "Code");
      radio=w.add("panel", undefined, "Choose Action");
      option1=w.add("radiobutton", undefined, "Action One");
      option2=w.add("radiobutton", undefined, "Action Two");
      option3=w.add("radiobutton", undefined, "Action Three");
      option4=w.add("radiobutton", undefined, "Action Four");
      option1.value = true;
      w.add ("button", undefined, "OK");
                  if (w.show() == 1){  
           if (option1.value == true)  
           {alert("Action One!"); exit();};
           if (option2.value == true)  
           {alert("Action Two!"); exit();};
           if (option3.value == true)  
           {alert("Action Three!"); exit();};
            if (option4.value == true)  
           {alert("Action Four!"); exit();};  


      Your comments are greatly appreciated.

      Except upgrading - that's not an option so far, sorry, Adobe...

        • 1. Re: Dialog with radiobuttons
          Jump_Over Level 5



          small modifications, try this:


            w=new Window("dialog", "Code"),
            radio=w.add("panel", undefined, "Choose Action"),
            option1=radio.add("radiobutton", undefined, "Action One"),
            option2=radio.add("radiobutton", undefined, "Action Two"),
            option3=radio.add("radiobutton", undefined, "Action Three"),
            option4=radio.add("radiobutton", undefined, "Action Four");  
          w.add ("button", undefined, "OK"); 
          option1.value = true;  
          radio.margins = [10,20,10,10];
          function handle_key (key)
            scope = radio.children.length,
            p, newPos, step;
            switch (key.keyName)
            case "Up": step = -1; break;
            case "Down": step = 1; break;
            default : return;
            for (p = 0; p < scope; p++)
            if (radio.children[p].value) {
            newPos = p + step;
            switch (newPos) {
            case scope: newPos = 0; break; // go to first
            case -1: newPos = scope - 1; // go to last
            radio.children[newPos].value = true;
            } // handle_key
          w.addEventListener ("keydown", function (k) {handle_key (k)});
          if (w.show() == 1){    
               if (option1.value) alert("Action One!");
               if (option2.value) alert("Action Two!");
            if (option3.value) alert("Action Three!");
            if (option4.value) alert("Action Four!");
          else {    


          Cant help you with strange mouse behavior (no idea )



          • 2. Re: Dialog with radiobuttons
            winterm Level 5

            Yeah, the first part of the question probably hasn't a simple answer. Just curious, is this strange mouse behavior unique to my system, otherwise well-tuned, fast and stable.

            As for the "real world" needs, ability to cycle with KB keys fits well for me.

            Thank You, Jarek.

            Bardzo dziękuję!