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

How do you change the color of the button?

Community Beginner ,
Jan 25, 2023 Jan 25, 2023

Copy link to clipboard

Copied

// ScriptUI graphics update issue

// resource string

var winRes = "dialog {  \
text: 'ScriptUI Graphics test',  \
margins: 15, \
alignChildren: 'row', \
\
    canvas: Panel {  \
        preferredSize: [100, 100], \
        properties: {borderStyle: 'black'} , \
    tempButton: Button { text: 'Examle'}, \
    }, \
    buttonsGroup: Group{ \
        cancelButton: Button { text: 'Cancel', properties:{name:'cancel'} }, \
        tryButton: Button { text: 'Try', properties:{name:'try'},size: [40,24], alignment:['right', 'center'] }, \
          }, \
}" 

// Window

var win = new Window(winRes);

// define the graphic property

win.canvas.graphics.backgroundColor = win.canvas.graphics.newBrush (win.canvas.graphics.BrushType.SOLID_COLOR, [1,0,0],1);

g = win.canvas.tempButton.graphics;
g.foregrounColor = g.newPen (g.PenType.SOLID_COLOR, [0,1,0],1);
win.canvas.tempButton.notify("onDraw");

win.buttonsGroup.tryButton.onClick = function() { // change the graphic background property by click on Button [try]

win.canvas.graphics.backgroundColor = win.canvas.graphics.newBrush (win.canvas.graphics.BrushType.SOLID_COLOR, [0,0,1],1);

}

win.show()

how do you change the color of the button «Examle» ?

TOPICS
Scripting

Views

233

Translate

Translate

Report

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
Guide ,
Jan 25, 2023 Jan 25, 2023

Copy link to clipboard

Copied

I think that color is only applied to containers, not elements.  You can put your button in a group and apply a color to the group. 

Votes

Translate

Translate

Report

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
LEGEND ,
Jan 25, 2023 Jan 25, 2023

Copy link to clipboard

Copied

You can also fake it with an icon button.

Votes

Translate

Translate

Report

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
Community Expert ,
Jan 25, 2023 Jan 25, 2023

Copy link to clipboard

Copied

check this ancient thread with many of the forum legends discussing this same topic

 

https://community.adobe.com/t5/indesign-discussions/js-cs3-4-scriptui-how-to-color-a-button/td-p/219...

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 28, 2023 Jan 28, 2023

Copy link to clipboard

Copied

Thank you for the answers!
Another question.
How to read and save a panel color value to return it as needed after changes.

Votes

Translate

Translate

Report

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
Guide ,
Jan 28, 2023 Jan 28, 2023

Copy link to clipboard

Copied

var w = new Window("dialog");
var g = w.add("group");
var b = g.add("button", undefined, "Click");
var color1 = g.graphics.newBrush(
        g.graphics.BrushType.SOLID_COLOR, [1, 0, 0, 1]);
var color2 = g.graphics.newBrush(
        g.graphics.BrushType.SOLID_COLOR, [0, 1, 0, 1]);
b.onClick = function() {
    if (String(g.graphics.backgroundColor.color) == String(color1.color)) {
        g.graphics.backgroundColor = color2;
    } else {
        g.graphics.backgroundColor = color1;
    }
}
w.show()

Votes

Translate

Translate

Report

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
LEGEND ,
Jan 28, 2023 Jan 28, 2023

Copy link to clipboard

Copied

LATEST

If you can find the ESTK installer, it has some sample scripts dealing with picking and using colors.

Votes

Translate

Translate

Report

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