10 Replies Latest reply on Apr 1, 2008 11:55 AM by (james_hendrickx)

    User Interface Questions

      I have already programmed some dialogs in JavaScript. I'm not using Script UI, although I've played around with Script UI a little bit. Now I'm getting a bit more advanced with some user interfaces and dialogs and have a few questions:

      1. Is it possible to create a "live updating" dialog similar to InDesign's Files > New > Document, where based on a menu selection of a preset, the dialog's editboxes change their values to reflect that menu selection?

      2. Can you program something like the Presets button in InDesign's New Document dialog where the user clicks "Save Preset", names it, and then the main dialog updates with the new preset the user just created.

      3. Script UI does not have measurement friendly boxes, does it? By that I mean that when you enter inches, mm or picas, the box will translate it into the current measurement type.

      4. I love the nudge option on the measurement editboxes. Can that be done via Script UI?

      Ideally my coding needs to work in both CS2 and CS3 and I code in JavaScript because that's what I know, but if the "live updating" stuff is possible in AppleScript or VBScript I'd still like to be aware that it can be done.

      While code examples of any of this are welcome, I mostly need to know what's possible, and any starting point you can offer will help (like the name of the control). That way I can start looking things up and figuring them out.

      Thanks in advance,
        • 1. Re: User Interface Questions
          Level 1
          1. Yes, with ScriptUI.

          2. Yes, with ScriptUI

          3. Nope, but you can create them yourself.

          4. Yes, it can, but you'll have to code it yourself. Not trivial.

          I have a ton of ScriptUI experience, so just ask away on how to get this stuff done.

          ScriptUI does not exist in ID CS2, by the way.


          • 2. Re: User Interface Questions
            Level 1
            Thanks for the answers Bob. They are exactly as I thought, but wanted to make sure. It sucks that we have to recreate (via code), things that were given to us before Script UI. I know Script UI is more powerful in some ways (and hopefully sure will get more powerful with time) but loosing measurement boxes is a big bummer. They had so many nice built in features. I feel like I need to reinvent the wheel with Script UI.

            1. Do you have any example dialogs that you could post? I can often figure out how to get a lot of stuff done by looking over examples other people have created. Especially things where one feature interacts with another, but even just a dialog with menus, text, etc so I can check out how to layout the dialog. I have created one dialog with Script UI, but am not sure if I am doing it very efficiently and I couldn't find any Script UI stuff in InDesign's sample scripts.

            2. I suspect if I use Script UI I'll have to verify that only numbers are entered into the edit fields right? I need numerical values only for what I will be doing. Any thoughts on the best way to verify it's only a number in there? Can I do that live in the dialog before the user clicks OK? Argh, all these complications make me less than enthusiastic to go to Script UI, but I really would like to be able to have a live updating dialog.
            • 3. Re: User Interface Questions
              Level 1
              OK, I've put together a demo file that shows the following:

              1. Creating a very simple dialog
              2. Validation for decimal number input into a text field (the text field turns red if the text field does not contain a decimal number, and the OK button disables)
              3. Storing the settings contained in the dialog in a preferences file and using the last "OK'd" values as default
              4. Allowing the user to store an arbitrary set of dialog settings (giving them a name), select stored settings from list, and populating the dialog from the selected settings.

              It's 318 lines long, way too big to post here. 226 of those lines are functions available in my script library. That library code makes all of the described ScriptUI functionality possible in 90 or so lines.

              If anyone would like a copy, please email me offline at rstucky@starband.net. I'll include the latest version of the script library (which is not yet available on my site www.creativescripting.net).


              • 4. Re: User Interface Questions
                Level 1
                Genius! Thanks soo much Bob.
                • 5. Re: User Interface Questions
                  Harbs. Level 6
                  > 4. Yes, it can, but you'll have to code it yourself. Not trivial.
                  Really? I spent considerable time trying to do that, and decided it
                  wasn't possible. (I assume he means the small nudge of the regular
                  widgets. As far as I know, there's no arrow key events. How would you
                  code that?

                  • 6. Re: User Interface Questions
                    Level 1
                    Your right, Harbs.

                    In fact, I remember looking at that with you back when. I just fergot.

                    Must have been all those drugs when I was younger.

                    • 7. Re: User Interface Questions
                      Level 1
                      While I like the interactions I can create with Script UI, for now I can't really use it since it doesn't work with CS2. That, and not having Measurement Editboxes are two things that kill it's usefullness for me currently. Here's to hoping CS4 will add more editbox types (and nudge keystrokes) to Script UI! There's no reason why the old type of dialog should have features that Script UI can't do. So I figure it's just a matter of time until Script UI gets updated so it has all the old stuff, plus all it's extras. Then I'll be a happy man.
                      • 8. Re: User Interface Questions
                        Hi Bob,
                        in a scriptUI dialog i've created a couple of editText objects, and entered a default value in all of them. When I tab into the first box however, the value doesn't get selected, as it does in the second, third etc. And the weird thing is: it works OK targeting ESTK (running in ESTK, obviously), but it works different targeting InDesign.

                        How can i get scriptUI to select the contents of the first textbox when tabbing into it?

                        • 9. Re: User Interface Questions
                          Level 1

                          ScriptUI isn't perfect. Sorry, but there are some quirks. Note that ScriptUI acts slightly differently in ID than in the ESTK. For example, when validating entries in an edit text, I like to turn the background color of the text box to red if they enter an invalid value. Works in the ESTK, works in Bridge, doesn't work in ID.

                          • 10. Re: User Interface Questions
                            Level 1
                            ouch... well, we'll have to live with that then...

                            thanks for telling me...