5 Replies Latest reply on Oct 18, 2011 5:34 AM by Andreas Jansson

    Mac/Win: button, button...

    vze26m98 Level 1

      Hi all-

       

      I've developed a dialog in ExtendScript using Mac InDesign CS5. I've now run it on Windows with InDesign CS4 and there are a few small alignment issues, but the biggest is some missing buttons:macwindialog.png

      I'm sure I'll get to the bottom of this, but I wonder if any veterans had words of advice, or pointers pertaining to button disappearance?

       

      Many thanks!

       

      Charles

        • 1. Re: Mac/Win: button, button...
          Andreas Jansson Level 2

          Are you using ScriptUI to build the interface, or the old style?


          What does the code look like, especially the part that defines the buttons?

          • 2. Re: Mac/Win: button, button...
            vze26m98 Level 1

            Hi Andreas-

             

            Thanks for your interest. I'm using ScriptUI and the code looks something like this:

             

            var w = new Window('dialog', selCnt + ' Sign(s) Selected', [100,100,670,670]);
            this.windowRef = w;
            
            w.p = w.add('panel', [25,15,545,520], 'Sign Info');
            
            w.p.add('statictext', [15,25,75,50], 'Type:');
            w.p.boxType = w.p.add('edittext', [15,50,75,72], DATA(0, colType));
            w.p.ddlTypes = w.p.add('dropdownlist', [76,50,101,72], lstTypes);
            w.p.ddlTypes.selection = setSel(w.p.boxType.text, lstTypes);
            w.p.ddlTypes.onChange = function (){
              // Don't take the descriptions as data:
              w.p.boxType.text = w.p.ddlTypes.selection.text.split('\t', 1).toString();
            };
            w.p.boxType.addEventListener('keydown', function (k)
            {
              if (k.keyName === 'Down') {
                w.p.ddlTypes.active = true;
                w.p.ddlTypes.selection += 1;
                w.p.boxType.active = true;
                }
              if (k.keyName === 'Up') {
                w.p.ddlTypes.active = true;
                w.p.ddlTypes.selection -= 1;
                w.p.boxType.active = true;
                }
            });
            
            [snip]
            
            w.p.cancelBtn = w.p.add('button', [298,445,388,85], 'Cancel');
            w.p.cancelBtn.onClick = function() {
              w.close(0);
            };
            w.p.applyBtn = w.p.add('button', [403,445,493,85], 'OK', {name: 'ok'});
            w.p.applyBtn.onClick = function() {
              w.close(1);
            };
            
            
            theResult = w.show();
            
            

             

            Perhaps no buttons on a panel in WIndows?

             

            Best wishes, Charles

            • 3. Re: Mac/Win: button, button...
              Andreas Jansson Level 2

              Hi!

               

              I believe it's something wrong with the "positioning numbers" in your code.

               

              I have never used this kind of exact positioning. Using a flow layout instead, you just add the elements, and on the parent element (and the element itself) you can set different kinds of alignment. If you would like to add more elements in between, it's much easier that way, and if you would like a resizable window, the elements would adapt to that without coding.

               

              This code worked for me (just removing the [11, 22, 33, 44] numbers (probably no need to move the button code, which I did while testing):

               

              var w = new Window('dialog', '' + ' Sign(s) Selected');

              this.windowRef = w;

               

              w.p = w.add('panel', undefined, 'Sign Info');

               

              w.p.add('statictext', undefined, 'Type:');

              w.p.boxType = w.p.add('edittext', undefined, '');

              w.p.ddlTypes = w.p.add('dropdownlist', undefined, Array('A','B'));

              w.p.ddlTypes.selection = 1;

               

              w.p.cancelBtn = w.p.add('button', undefined, 'Cancel');

              w.p.cancelBtn.onClick = function() {

                w.close(0);

              };

              w.p.applyBtn = w.p.add('button', undefined, 'OK', {name: 'ok'});

              w.p.applyBtn.onClick = function() {

                w.close(1);

              };

               

               

              w.p.ddlTypes.onChange = function (){

                // Don't take the descriptions as data:

                w.p.boxType.text = w.p.ddlTypes.selection.text.split('\t', 1).toString();

              };

              w.p.boxType.addEventListener('keydown', function (k)

              {

                if (k.keyName === 'Down') {

                  w.p.ddlTypes.active = true;

                  w.p.ddlTypes.selection += 1;

                  w.p.boxType.active = true;

                  }

                if (k.keyName === 'Up') {

                  w.p.ddlTypes.active = true;

                  w.p.ddlTypes.selection -= 1;

                  w.p.boxType.active = true;

                  }

              });

               

               

               

              theResult = w.show();

              • 4. Re: Mac/Win: button, button...
                vze26m98 Level 1

                Hi Andreas-

                 

                Very kind of you to go to all that trouble on my behalf.

                 

                You're exactly right; embarrassed to say I erred with my bounds specification on the buttons. OSX seems to produce Aqua buttons when the bounds are nonsense, where Windows doesn't produce anything. If they're specified correctly, I get "Adobe"-look buttons on the Mac.

                 

                Thanks for the tip about flow. I was suspicious of it, but perhaps I should give it a chance.

                 

                Thanks again!

                 

                Charles

                • 5. Re: Mac/Win: button, button...
                  Andreas Jansson Level 2

                  I'm just happy I could help you :-)

                   

                  I've been using a program called Rapid ScriptUI for interface design. It can be a great help, and is not very expensive, considering the time you can save on more complex interfaces compared to writing the code by hand.

                   

                  Message was edited by: Andreas Jansson removed a couple of lines, since they were obviously wrong. I didn't have the latest version.