7 Replies Latest reply on Mar 6, 2014 3:30 PM by pixxxel schubser

    quick syntax question

    mec_os Level 3

      in the extendscript documentation it says you can assign a name to UI elements at creation like the example given below

       

      dlg.btnPnl.cancelBtn = dlg.btnPnl.add('button', undefined, 'Cancel',

      {name:'cancel'});

       

      but when i do it like that, the bject's name comes out as undefined when accessed like this

      dlg.btnPnl.cancelBtn.name

      or like this:

      dlg.btnPnl.children['name']

       

      but adding the object then naming like this works-

       

      dlg.btnPnl.cancelBtn.name = "Cancel";

       

      i'm using illustrator cc and the extendscript guide for cs6 (couldn't find a newer one).

      did the syntax change?

        • 1. Re: quick syntax question
          pixxxel schubser Level 5

          Hi mec_os,

          I haven't CS6 here and no CC at work.

          But one syntax ever works since years ago (I don't need the name property):

           

          dlg.btnPnl.cancelBtn = dlg.btnPnl.add('button', undefined, 'Cancel');

           

           

          If you really want to try 'Your' syntax, here is an example written by artchrome.

          http://forums.adobe.com/message/2757538#2757538

           

          Have fun

           

          • 2. Re: quick syntax question
            CarlosCanto Adobe Community Professional & MVP

            use this syntax

             

            alert(dlg.btnPnl.cancelBtn.properties.name);
            
            1 person found this helpful
            • 3. Re: quick syntax question
              mec_os Level 3

              that works! thank you carlos. you are godly.

               

               

              i don't really need to name my UI object, i just got baffled why i couldn't make it work.

              • 4. Re: quick syntax question
                CarlosCanto Adobe Community Professional & MVP

                yeah, I did have to name a set of buttons on one of my scripts and I was pulling my hair trying get the name out of them...

                • 5. Re: quick syntax question
                  pixxxel schubser Level 5

                  I'm a little bit confused.

                  Careful reading of the linked thread gives you the same answer.

                   

                  artchrome wrote:

                  var ressource="dialog {  \
                  text: 'FRONT or BACK SELECTOR', frameLocation:[100,100], \
                  MyPanel: Panel { orientation:'column', alignChildren:['left','Top'], \
                                 text: 'Option FRONT&BACK', \
                                 title: Group { orientation: 'column',  \
                                           FrontVar: RadioButton { alignment:'left', text: 'FRONT select ?', value:true}, \
                                           BackVar: RadioButton { alignment:'left', text: 'BACK select ?', value:false}, \
                                                 CancelBtn: Button { text: 'Cancel', properties:{name:'cancel'} }, \
                                                 OkBtn: Button { text: 'Valid', properties:{name:'ok'} }, \
                                              }  } \
                  }";
                  • 6. Re: quick syntax question
                    mec_os Level 3

                    the question was not how to create the button, but why when you created it in that specific syntax you can't use the syntax "button.name" to retrieve the name from the element. you have to use "button.properties.name" like carlos says. i couldn't figure that out.

                     

                    if you assign the name property after creating the object you can.

                    example;

                     

                    button.name = "name";

                     

                    then you can call it like so;

                     

                    "button.name"

                     

                     

                    sorry for the confusion.

                    • 7. Re: quick syntax question
                      pixxxel schubser Level 5

                      Okay. I thought it would be clear.

                       

                      In the linked script artchrome named his button with:

                      dlg - MyPanel - title - CancelBtn - properties:{name:'cancel'}

                      and of course you can call the name of the button with:

                      alert(dlg.MyPanel.title.CancelBtn.properties.name)

                       

                      Regards

                      pixxxelschubser