4 Replies Latest reply on Aug 12, 2016 2:03 AM by Trevorׅ

    ScriptUI Borderless Buttons

    frameexpert Level 4

      Hello All,

       

      I am trying to create a palette with a series of buttons. I want the buttons to appear with just the text and spaced close together, similar to a Word toolbar. I am not sure which properties to customize on each button. Any help or directions on where to start will be appreciated. Thank you very much.

       

      Rick

       

      Example.png

        • 1. Re: ScriptUI Borderless Buttons
          drerol74 Level 2

          Hello Rick,

          you can simulate a button with a group and statictext:

           

          #targetengine "test"
          
          __showUI ();
          
          function __showUI() {
              
              var _colorDefault = [0.2,0.2,0.2];
              var _colorMouseover = [0.0,0.3,0.9];
              var _colorMousedown = [0.0,0.0,0.4];
              
              var _ui = new Window("palette", undefined, undefined, { closeButton: true });
              with (_ui) {
                  margins = [70,40,70,45];
                  var _buttonGroup = add("group");
                  with(_buttonGroup) {
                      margins = [10,6,10,6];
                      graphics.backgroundColor = graphics.newBrush(graphics.BrushType.SOLID_COLOR, _colorDefault, 1);
                      var _label = add("statictext", undefined, "Click me");
                      with(_label) {
                          justify = "center";
                          graphics.foregroundColor = graphics.newPen(graphics.PenType.SOLID_COLOR, [0.9, 0.9, 0.9], 1);
                      }
                  }
              }
          
              _buttonGroup.addEventListener("click", function() {
                   this.children[0].text = "Thanks";
                   $.sleep(800);
                   this.children[0].text = "Click me";
              });
          
              _buttonGroup.addEventListener("mouseover", function() {
                  this.graphics.backgroundColor = this.graphics.newBrush(this.graphics.BrushType.SOLID_COLOR, _colorMouseover, 1);
              });
          
              _buttonGroup.addEventListener("mouseout", function() {
                  this.graphics.backgroundColor = this.graphics.newBrush(this.graphics.BrushType.SOLID_COLOR, _colorDefault, 1);
              });
          
              _buttonGroup.addEventListener("mousedown", function() {
                  this.graphics.backgroundColor = this.graphics.newBrush(this.graphics.BrushType.SOLID_COLOR, _colorMousedown, 1);
                  $.sleep(120);
                  this.graphics.backgroundColor = this.graphics.newBrush(this.graphics.BrushType.SOLID_COLOR, _colorMouseover, 1);
              });
          
              _ui.show();
          }
          

           

           

          Roland

          • 2. Re: ScriptUI Borderless Buttons
            Trevorׅ Adobe Community Professional

            Hi Roland & Rick

             

            The static text approach will only work on CS, the later CC version don't accept those eventListners which is a real pain in the neck.

            Better to go for a transparent icon button with the style set to toolbutton and use a stack orientation to place the button text.

            The size of the button can be adjusted according to the size of the text.

             

            HTH

             

            Trevor

            • 3. Re: ScriptUI Borderless Buttons
              drerol74 Level 2

              Hello Trevor,

              it works for me under cs6 and CC 2015.3. Which OS do you use?

              https://www.rolanddreger.net/owncloud/index.php/s/y5CMHTBbKO1MLSY

               

              Roland

              • 4. Re: ScriptUI Borderless Buttons
                Trevorׅ Adobe Community Professional

                10.11.6 El Captain (Mac)