2 Replies Latest reply on Nov 29, 2011 5:41 AM by Loic.Aigon

    ScriptUI and weird Object behaviour

    Loic.Aigon Adobe Community Professional

      Hi,

       

      I am working on a galaxy of little helpers that all share a same scriptUI dialog script (include). I have included an option to add window components from the helper thanks to a function:

       

      function ExtraUIItems(parentContainer){
           //Adding UI elements
           this.getItem = function(){
                return {
                     choice:"a",
                     style:"b"
                }
           }
      }
      

       

       

      so in the scriptUI general code, I check for a flag and add item if needed :

       

      var extraItems = new ExtraUIItems(w);
      

       

      and then when I need datas, I call the getItem function

       

      extraItems.getItem();
      

       

      Problem is :

       

      extraItems.getItem().style //"b" => OK
      extraItems.getItem().choice //undefined
      //and 
      extraItems.getItem().toSource() // {style:"b"} => no evidence of choice property
      
      //If I mistype style on purpose, ask for toSource() again,  and rerun the script
      extraItems.getItem().toSource() //{} => No properties at all
      

       

      I thought about initialization but even restarting InDesign doesn't solve it .

       

      My question is : WTH Am I doing wrong ?

       

      TIA

       

      Loic

        • 1. Re: ScriptUI and weird Object behaviour
          கற்பனை (Imagine) Level 3

          Hi Loic,

           

          I've tried ur codes,  getting the proper results that on Win7/InDesign CS5.5.   Give details about OS/ID versions.

          • 2. Re: ScriptUI and weird Object behaviour
            Loic.Aigon Adobe Community Professional

            Hi and thank you a lot for your concern,

             

            It seems my issue is more related to doScript after all. I am passing the result of getItem() as a param to doScript and then comes the issue.

             

            For example:

             

             

            var params = [app.activeDocument,{choice:"b"}];

             

            function test(){

              var o = arguments[0][1];

              alert(o.reflect.properties);

            }

             

             

            app.doScript(test, undefined, params , UndoModes.ENTIRE_SCRIPT); //No choice property

             

            test(params); //Choice Ok

             

             

             

            [EDIT]

            Yes that was all about doScript and how to pass an object as parameter.

             

             var params = [app.activeDocument,{choice:"b"}.toSource()];
            
            function test(){
              var o = arguments[0][1];
            o = eval( "(" +o +")" );
              alert(o.reflect.properties);
            }
            
            app.doScript(test, undefined, params , UndoModes.ENTIRE_SCRIPT); //Choice Ok
            

             

             

            But for what is worth I am on Mac OS 10.7.2

             

            Thanks a lot,

             

            Loic