5 Replies Latest reply on Apr 9, 2011 6:00 AM by Jimbo Jackson

    precise placement of radio button elements

    JJ Fulks Level 1

      I'm wanting to arrange a group of radio buttons so that they appear on the UI as two columns of radio button options, but only belonging to a single group .... and not two groups with column orientation.

        • 1. Re: precise placement of radio button elements
          John Hawkinson Level 5

          That's the whole point of groups, sorry. Why are you reluctant to use groups for this? I do not think you can achieve it any other way.

          • 2. Re: precise placement of radio button elements
            Jimbo Jackson

            John, I do use group containers to hold elements like this almost always, but please tell me if I'm mistaken as I'm new to ScriptUI. From what I am experiencing, a single radio button group cannot be spread across two group containers and function as one. For example, if I've got four radio buttons that I want arranged in a pattern of two columns and two rows, and I want the group of buttons to function as they should with only one radio button capable of being enabled at any given time, having them aligned to the left in each column, then the only way to do this is to put them in a single group container and arrange them based on a coordinate system (?)

             

            Thanks for your help!

            • 3. Re: precise placement of radio button elements
              Jimbo Jackson Level 1

              and sorry for the confusion, I am the "JJ" who started this thread ... account issues with my original account. 

              • 4. Re: precise placement of radio button elements
                Peter Kahrel Adobe Community Professional & MVP

                You don't need the coordinate system. The idea of radiobuttons is that when you click one in a group, all the others in the same group are unmarked. But you can have radiobuttons in two or more groups, say, group A and group B and add eventlisteners that unmark all buttons in B if you click a button in A and the other way around:

                 

                var w = new Window ('dialog');
                   w.orientation = 'row';
                   var p1 = w.add ('panel');
                      p1.add ('radiobutton', undefined, 'rb 1');
                      p1.add ('radiobutton', undefined, 'rb 2');
                      p1.add ('radiobutton', undefined, 'rb 3');
                   var p2 = w.add ('panel');
                      p2.add ('radiobutton', undefined, 'rb 4');
                      p2.add ('radiobutton', undefined, 'rb 5');
                      p2.add ('radiobutton', undefined, 'rb 6');
                   p1.children[0].value = true;
                   
                   p1.addEventListener ('click', function ()
                      {
                      for (var i = 0; i < p2.children.length; i++)
                         p2.children[i].value = false;
                      }
                   );
                   
                   p2.addEventListener ('click', function ()
                      {
                      for (var i = 0; i < p1.children.length; i++)
                         p1.children[i].value = false;
                      }
                   );
                   
                w.show();

                 

                 

                Peter

                • 5. Re: precise placement of radio button elements
                  Jimbo Jackson Level 1

                  Peter, thanks for the explanation and the example. I thought there must be a shorter, more simple way to handle this, since this kind of layout with radiobuttons is quite common. But, your example is a very nice way of handling the problem, and it is a lot more simple than using coordinates (which I discovered in the tool guide a few hours ago, and have yet to make it work properly .. ).

                   

                  Thanks again!