1 Reply Latest reply on Jun 8, 2016 12:37 AM by brunoj62734382

    buttons desappear when i set the size of the alert window


      Good morning all,

      My question of the day :

      My project works fine (onclick-button name or ID ), but now i would like to set the height of the alert window containing my set of buttons.

      i set the window location at the top of the screen like this:

      win.frameLocation = [800,0];

      then my buttons are created dynamically (the number of buttons can change)


      i set the size of the window for exemple with:

      win.size = [1024, 50];

      but the buttons desappear ...

      i tried to place the code before or after the button creation , but it doesn't work...

      well.. before i dive in a "no ending" exploration due to my poor knowledge in js , could you give me a track or a direction to explore ...

      Thank you !


      the code:


      var mainFolder = "myBibScript"; // nom du dossier pricipale (root folder of the project)

      var mainPath = "/Volumes/myTools/scripts - macros/jsPalette/myBibScript/" ; // chemin du dossier pricipale (path)


      var scriptFolder= new Folder(mainPath+"scpt/");  // dossier des scripts dans le dossier principale (scripts folder in the root folder)

      var files = scriptFolder.getFiles("*.*");



      var ui = // dialog resource object

          "dialog {\

              gButtons: Group { \

                  orientation: 'row', alignment: 'right'\

                   } } \

              } \



      var win = new Window(ui);

      //positionne la fenêtre (window position)

      win.frameLocation = [800,0];


      //color background

      g = win.graphics;

      myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.45, 0.75, 0.75, 1]);

      g.backgroundColor = myBrush;



      win.scptFiles = new Array();        //  tableau des fichiers scripts

      myScriptName= new Array();      //  tableau des noms des scripts


      // boucle le dossier des scripts (loop  the scripts folder)

      var counter = 0;

          for (var loop=0; loop < files.length; loop++) {                             // Add items dynamically

              var f = files[loop];

              if (typeof f.open == "undefined")    continue;                           // Skip folder

              if ( -1 != f.fsName.indexOf(".DS_Store"))    continue;              // Skip Mac's hidden file

      var fName=f.fsName.substring(scriptFolder.fsName.length+1);      //extract filename only

      var fNameShort =fName.replace(".jsx", "");                                     // nom sans l'extension (remove extension)



      // creation des icones boutons (create icon buttons)

      var f = File(mainPath+"/img/"+fNameShort+".jpg")

      var myBtn=win.gButtons.add("iconbutton" , undefined , ScriptUI.newImage(f),{style: "toolbutton" , toggle: false});


      //remplissage du tableau de "title" avec l'index (counter) des boutons créés

      // i use numbers for "titles" in place of names to have a short line displayed


      win.scptFiles[counter++] = myBtn




      myBtn.size = [48, 38];


      win.gButtons.children[counter-1].onClick = gButtonsOnClick




      function gButtonsOnClick() {

      var myScriptTitle=this.title;        // index du bouton cliqué

      myScriptFile=myScriptName[myScriptTitle]          // nom de l'image/script correspondant à l'index




      var idAdobeScriptAutomationScripts = stringIDToTypeID( "AdobeScriptAutomation Scripts" );

          var desc635 = new ActionDescriptor();

          var idjsCt = charIDToTypeID( "jsCt" );

          desc635.putPath( idjsCt, new File( scriptFolder+"/"+myScriptFile+".jsx") );

          var idjsMs = charIDToTypeID( "jsMs" );

          desc635.putString( idjsMs, """[ActionDescriptor]""" );

      executeAction( idAdobeScriptAutomationScripts, desc635, DialogModes.NO);