15 Replies Latest reply on Jul 7, 2008 10:51 AM by (xbytor)

    UI radio button...

    Emanuele Radaelli Level 1
      Hello everybody!

      First time with UI in ID CS3... and it's really a bit difficult to me.
      I'm trying to reproduce the JPG exporting interface (without options, which are setted within the script).
      I have 2 radio buttons, one to export all pages and the other to export just a range defined by the user (so, when this one's checked the EditText becomes active...).
      First step: I create a group which contains the radio buttons but I can't check the right one because both are selected.
      That's the script:

      sel =
      "dialog { \
      info: Panel { orientation: 'column', alignChildren: 'right', \
      text: 'Seleziona le pagine da esportare', \
      rb: Group { orientation: 'column', alignChildren: 'left', \
      seleziona: Group { orientation: 'row', \
      seleziona_rb: RadioButton { text: 'seleziona', value: 'false' }, \
      seleziona_txt: EditText { preferredSize: [200,20]} \
      }, \
      tutto_rb: RadioButton { text: 'Tutte', value: 'true' } \
      } \
      }, \
      buttons: Group { orientation: 'row', \
      okBtn: Button { text:'OK', properties:{name:'ok'} }, \
      cancelBtn: Button { text:'Cancel', properties:{name:'cancel'} } \
      } \
      }";
      win = new Window (sel);
      win.center();
      win.show();

      Sorry for my bad english, hope you unerstood.
      Thanks in advance for your precious help!
        • 1. Re: UI radio button...
          Loic.Aigon Adobe Community Professional
          Hi,
          Basically radiobuttons are meant to be exclusive each others. In basic dialogs, you create a readiobutton group then the radiobutton itselves.
          I don't know how to set the exclusion factor in UI but in standard dialog script you will get this result very easy. In fact I don't see what is so worth to use UI in your purpose.
          By the way, you can get your script in a very easy way.
          Considering you wrote the export section of the code :
          var mypagerange;
          var myinput = prompt("Set a range of pages to export as jpgs","all","JPG page range exporter");
          if(myinput == "all")
          {
          mypagerange = "1-"+(app.activeDocument.pages.length-1);
          }
          else
          {
          mypagerange = myinput;
          }
          exportJpeg(mypagerange);
          You will probably need to set a condition like :
          if myinput == "all" or myinput looks like x-y with x & y valid pages
          export();

          So at the end, you just launch the script, be requested for the page range (default is "all"), then click ok to have the pages exported.
          Maybe you want to have the choice to use a standard folder (the one of the indesign document for example) or a specific folder (so you prompt the user to choose a folder). Up to you.
          Hope it helps.
          Loic
          • 2. Re: UI radio button...
            Loic.Aigon Adobe Community Professional
            Hope it helps.
            Loic
            • 3. Re: UI radio button...
              Peter Kahrel Adobe Community Professional & MVP
              Strangely, this query and two responses were copied to http://www.adobeforums.com/webx/.3bbf275d.59b5a0b2/8

              Peter
              • 4. Re: UI radio button...
                Emanuele Radaelli Level 1
                Thanks a lot guys...
                So, new version will look like this:

                res =
                "dialog { \
                info: Panel { orientation: 'row', alignChildren: 'fill', minimumSize: [200, 100], text: 'Seleziona le pagine da esportare', \
                rb: Group { orientation: 'row', alignChildren: 'top', \
                seleziona: Group { orientation: 'column', alignChildren: 'left', \
                seleziona_rb: RadioButton { text: 'seleziona', value: 'false' }, \
                tutti_rb: RadioButton { text: 'tutti', value: 'true' } \
                }, \
                testo: Group { orientation: 'column', \
                testo_rb: EditText { preferredSize: [200, 20], active:'false' } \
                }, \
                } \
                }, \
                buttons: Group { orientation: 'row', \
                okBtn: Button { text:'OK', properties:{name:'ok'} }, \
                cancelBtn: Button { text:'Cancel', properties:{name:'cancel'} } \
                } \
                }";

                win = new Window (res);
                win.center();
                win.show();

                But again, I have a few problems:
                - I set the EditText to "active:'false'" but it's active.
                - I tried "seleziona_rb.onClick = function();" but it doesn't work, how can I refer to that radio button?

                Thanks again guys!
                • 5. Re: UI radio button...
                  Peter Kahrel Adobe Community Professional & MVP
                  >I set the EditText to "active:'false'" but it's active.

                  Just leave that statement out (bizarrely) so that that line reads:
                  > seleziona_rb: RadioButton { text: 'seleziona'}, \

                  >I tried "seleziona_rb.onClick = function();" but it doesn't work

                  You need to use the button's full "path name":

                  >win.info.rb.seleziona.seleziona_rb.onClick = function()

                  Peter
                  • 6. Re: UI radio button...
                    Emanuele Radaelli Level 1
                    Thanks Peter,
                    but I was refering to the EditText "active" property which initially has to be "false" (the edit box has not to be active...)

                    testo_rb: EditText { preferredSize: [200, 20], active:'false' }
                    • 7. Re: UI radio button...
                      Peter Kahrel Adobe Community Professional & MVP
                      You should remove the quotation marks for it to work properly:

                      >testo_rb: EditText { preferredSize: [200, 20], active:false }

                      Peter
                      • 8. Re: UI radio button...
                        Emanuele Radaelli Level 1
                        Yes, yes, yes... my fault!
                        Thanks again Peter!
                        • 9. Re: UI radio button...
                          Level 1
                          Hi cinematomico,

                          Just a note--it's *much* easier to create ScriptUI controls item by item, rather than using the reference string. That way, you can debug each line of the dialog/window. Take a look at the ScriptUI dialog inside the AddGuides.jsx example script to see how to do that.

                          I think it's unfortunate that the JavaScript Tools Guide shows most of its examples in the string resource format--it makes it look as if that's the preferred approach. Not only is it not the best approach (in my opinion), but it makes it much harder for people new to ScriptUI to construct their first few dialogs.

                          Thanks,

                          Ole
                          • 10. Re: UI radio button...
                            Harbs. Level 6
                            Just to add to Ole's comment:

                            The only advantage I see to the reference string approach, is that it's
                            easy to see the structure of the dialog (similar to "with" statements in
                            regular dialogs). But like Ole, I find them very difficult to work with.

                            Harbs
                            • 11. Re: UI radio button...
                              Level 1
                              Concur 100%, even more, if that's possible.

                              I did one window with a resource definition, and was horrified at the debugging process. I've done hundreds by adding them item by item in code.

                              Regards

                              Bob
                              • 12. Re: UI radio button...
                                Peter Kahrel Adobe Community Professional & MVP
                                >I did one window with a resource definition, and was horrified at the debugging process.

                                Same here. That put me off resource strings for good. Anothor advantage of the item-by-item approach is that you have much easier access to window elements like buttons and text fields.

                                Peter
                                • 13. Re: UI radio button...
                                  Level 1
                                  Peter Kahrel wrote:
                                  >
                                  > I did one window with a resource definition, and was horrified at the
                                  > debugging process.
                                  >
                                  > Same here. That put me off resource strings for good. Anothor advantage of the item-by-item approach is that you have much easier access to window elements like buttons and text fields.
                                  >

                                  Adobe, however, seems comfortable with resource definitions because they use
                                  them all over the place. I suspect that they have some in-house WYSIWYG tool for
                                  constructing resource-based UIs. Doing it manually is just too much grief.
                                  I've also had enough issues with the ScriptUI automatic layout features across
                                  release of CS that I just don't use them. I have ScriptUI code that has to work
                                  with at least 3 different versions of PS, so the only thing I can do is pixel
                                  placement for widgets. Even then, there are adjustments that I have to make
                                  between CS2/CS3 to get things to align correctly.

                                  Of course, backwards/forwards ScriptUI compatibility with ID is not going to be
                                  a problem for me until CS4 :)

                                  -X
                                  • 14. Re: UI radio button...
                                    Level 1
                                    xbytor wrote: "Adobe, however, seems comfortable with resource definitions because they use them all over the place."

                                    Actually, there are several tools floating around the company (and outside the company, as well), but I don't use them--and I don't think that the people who wrote the ScriptUI documentation examples do, either. I think that they're just so familiar with ScriptUI that they don't even think about it.

                                    Thanks,

                                    Ole
                                    • 15. Re: UI radio button...
                                      Level 1
                                      > Actually, there are several tools floating around the company (and outside the company, as well), but I don't use them--and I don't think that the people who wrote the ScriptUI documentation examples do, either. I think that they're just so familiar with ScriptUI that they don't even think about it.

                                      The only one I've got my hands on was a flash-based tool a PS scripter wrote
                                      back in CS1 days. It was a bit primitive, but worked fine for very simple UIs.
                                      http://www.jkozniewski.com/tools/csuib.html

                                      If you have any pointers to anything else, I'd be more than happy to try and get
                                      some use out of it.

                                      -X
                                      --
                                      for photoshop scripting solutions of all sorts
                                      contact: xbytor@gmail.com