0 Replies Latest reply on Feb 11, 2014 10:22 AM by NoPrevaricator

    Floating Palette (InDesign CC Mac)

    NoPrevaricator Level 1

      Hello fellow Javascripters!

       

         I am attempting to get a floating palette to work but though the script seems to work without an error, the floating palette never appears.  Here's the script (Note it is based off of the SnpCreateSlider.jsx example):

       

      main();

       

      var gAddButton;

      var gRemoveButton;

      var gMoveButton;

      var gJustifyButton;

       

      var gRowCt;

      var gColCt;

       

      function HachUI()

      {

           this.windowRef = null;

      }

       

      HachUI.prototype.run = function()

      {

          var ButtonPalette = new Window("palette", "Button Mover", [ 10,10, 500,500]);

          this.windowRef = ButtonPalette;

         

         //ButtonPalette.frameLocation = [10, 500];

         

          ButtonPalette.RowPanel = ButtonPalette.add('panel', undefined, "Specify row and column values");

          ButtonPalette.RowPanel.add('statictext', [5,10,25, 100], "# rows: ");

          var RowText = ButtonPalette.RowPanel.add('edittext', [5,105,25,145], "25") ;  // Row data

         

          ButtonPalette.RowPanel.add('statictext', [5,150,25, 175], "# cols: ");

          var ColText = ButtonPalette.RowPanel.add('edittext', [5,180,25,220],  "10");  //  column data

         

          ButtonPalette.ButtonPanel = ButtonPalette.add('panel', undefined, "Choices");

         

          ButtonPalette.ButtonPanel.gAddButton       = ButtonPalette.ButtonPanel.add("button", [5,10,25,40],"A");  //  for add object blocks

          ButtonPalette.ButtonPanel.gRemoveButton = ButtonPalette.ButtonPanel.add("button", [5,10,25,40],"R");  //  for remove object blocks

          ButtonPalette.ButtonPanel.gRemoveButton.enabled = false;

         

          ButtonPalette.ButtonPanel.gMoveButton     = ButtonPalette.ButtonPanel.add("button", [5,10,25,40],"M");  //  For "move button"

          ButtonPalette.ButtonPanel.gMoveButton.enabled = false;

         

          ButtonPalette.ButtonPanel.gJustifyButton    = ButtonPalette.ButtonPanel.add("button", [5,10,25,40],"J");  // for Justify button

          ButtonPalette.ButtonPanel.gJustifyButton.enabled = false;

         

          //  Handlers

          //  First Edit Text fields.

          ButtonPalette.ButtonPanel.RowText.onClick = function()

          {

              gRowCt = RowText.text.valueOf();

          }

       

         

          ButtonPalette.ButtonPanel.ColText.onClick = function()

          {

              gRowCt = ColText.text.valueOf();

          }

       

          //  Now the buttons.

          ButtonPalette.ButtonPanel.gAddButton.onClick = function()

          {

              gAddButton.enabled = false;

              gRemoveButton = true;

             

              AddBlocks(gRowCt, gColCt);

          }

       

          ButtonPalette.ButtonPanel.gRemoveButton.onClick = function()

          {

              gAddButton.enabled = true;

              gRemoveButton.eenabled = false;

              RemoveBlocks();

          }

         

          ButtonPalette.ButtonPanel.gMoveButton.onClick = function()

          {

              if(app.selection.length != 2)

                 alert("Select the button and then the block...in that order.");

              else

                 MoveTheButton();

          }

       

          ButtonPalette.ButtonPanel.gJustifyButton.onClick = function()

          {

                alert("Not yet implemented.");

          }

       

          ButtonPalette.show();

         

      }

       

      function RemoveBlocks()

      {

         //  Do interesting stuff...

       

      }

       

      function RemoveColor()

      {

         //  Do interesting stuff...

      }

       

      function AddBlocks(nrow, ncol)

      {

         //  Do interesting stuff...
         

      }

      function RemoveSquares()

      {

         //  Do interesting stuff...

      }

       

      function AddWorkingColor()

      {

          //  Do interesting stuff...

      }

      function AddSquares(nrow, ncol)

      {

         //  Do interesting stuff...   

      }

       

      function main()

      {

         

          if(this.windowRef != null)

             new HachUI().run();

      }

       

      I cut a lot of the code in the standalone functions to reduce the size of the posting.  I will be happy to share it with anyone who would like to see it.

       

      R,

      John