Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ScriptUI Borderless Buttons

Community Expert ,
Aug 11, 2016 Aug 11, 2016

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

TOPICS
Scripting
695
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 11, 2016 Aug 11, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Aug 12, 2016 Aug 12, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 12, 2016 Aug 12, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Aug 12, 2016 Aug 12, 2016
LATEST

10.11.6 El Captain (Mac)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines