Changing enable=true to false in Script Up dialog

Advocate ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

A Script UI diagog question... 

How can I change the enabled=true/false status of text a and b text inside a windows script, when the dialog is still open.
I have try adding this at the end but nothing happens.
if (checkbox1.value == true);
a.enabled = false;​

var w = new Window("dialog"); 

    var checkbox1 = w.add("checkbox", undefined, undefined, {name: "checkbox1"}); 
    checkbox1.text = "a check box"; 

var a = w.add('edittext {justify: "center", properties: {name: "a"}}'); 
    a.preferredSize.width = 100; 

var b = w.add('edittext {justify: "center", properties: {name: "b"}}'); 
    b.preferredSize.width = 100; 

var button1 = w.add("button", undefined, undefined, {name: "button1"}); 
    button1.text = "OK"; 

w.show();

Thanks!

TOPICS
Scripting

Views

171

Likes

translate

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

correct answers 1 Correct Answer

Adobe Community Professional , Sep 21, 2020 Sep 21, 2020
Add an onClick handler:  var w = new Window("dialog"); var checkbox1 = w.add("checkbox", undefined, undefined, {name: "checkbox1"}); checkbox1.text = "a check box"; checkbox1.onClick = function() { if (checkbox1.value == true) { a.enabled = false; } else { a.enabled = true; } } var a = w.add('edittext {justify: "center", properties: {name: "a"}}'); a.preferredSize.width = 100; var b = w.add('edittext {justify: "center", properties: {name: "b"}}'); b....

Likes

translate

Translate

Translate
Adobe Community Professional ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

Put that code inside the onClick event handler of checkbox. See the following

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#CheckboxSUI.html

-Manan

 

Likes

translate

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
Adobe Community Professional ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

Add an onClick handler: 

var w = new Window("dialog"); 

var checkbox1 = w.add("checkbox", undefined, undefined, {name: "checkbox1"}); 
    checkbox1.text = "a check box"; 

    checkbox1.onClick = function() {
        if (checkbox1.value == true) { a.enabled = false; }
        else { a.enabled = true; }
    }

var a = w.add('edittext {justify: "center", properties: {name: "a"}}'); 
    a.preferredSize.width = 100; 

var b = w.add('edittext {justify: "center", properties: {name: "b"}}'); 
    b.preferredSize.width = 100; 

var button1 = w.add("button", undefined, undefined, {name: "button1"}); 
    button1.text = "OK"; 

w.show();

Likes

translate

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
Advocate ,
Sep 21, 2020 Sep 21, 2020

Copy link to clipboard

Copied

Thanks Brian! 
Thanks also Manan for the link. I was not even aware there was a CC2020 API Object Model available.

Likes

translate

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