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

How to disable a textBox or dropdown in a dialog

Explorer ,
Mar 07, 2018 Mar 07, 2018

Hi!

I have a dialog with a group of 4 radio buttons, & each radio button option has a textBox or dropdown, see screenshot:Screenshot 2018-03-08 00.57.38.png

How do I enable only the dropdown or textBox of the selected radioButton?!

Thanks a lot in advance!!!

TOPICS
Scripting
1.6K
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

correct answers 1 Correct answer

People's Champ , Mar 07, 2018 Mar 07, 2018

Here is a possible approach:

var w = new Window('dialog'),

g = w.add('group')

g1 = g.add('group'),

g2 = g.add('group'),

btn = w.add('button', undefined, "Cancel"),

cb, dd;

for ( i = 0; i < 5; i++ ) {

cb  = g1.add('checkbox',undefined,(i+1));

cb.index = i;

cb.alignment = "fill";

dd  = g2.add('dropdownlist',undefined,(i+1));

dd.enabled = false;

dd.alignment = "fill";

}

g1.addEventListener ('mousedown', function(evt){

var cb  = evt.target, index, n = g1.children.length, cb, dd, value;

if(cb.constructor.name != "Che

...
Translate
People's Champ ,
Mar 07, 2018 Mar 07, 2018

Here is a possible approach:

var w = new Window('dialog'),

g = w.add('group')

g1 = g.add('group'),

g2 = g.add('group'),

btn = w.add('button', undefined, "Cancel"),

cb, dd;

for ( i = 0; i < 5; i++ ) {

cb  = g1.add('checkbox',undefined,(i+1));

cb.index = i;

cb.alignment = "fill";

dd  = g2.add('dropdownlist',undefined,(i+1));

dd.enabled = false;

dd.alignment = "fill";

}

g1.addEventListener ('mousedown', function(evt){

var cb  = evt.target, index, n = g1.children.length, cb, dd, value;

if(cb.constructor.name != "Checkbox") return;

index = cb.index;

value = !cb.value;

while ( n-- ) {

dd = g2.children;

cb = g1.children;

dd.enabled = !value? false : ( n == index );

value && n != index && cb.value = false;

}

});

g1.children[0].value = true;

g2.children[0].enabled = true;

g1.orientation = g2.orientation = "column";

g.orientation = "row";

w.show();

Although I would process differently myself using constructors and somme event programming:

Event-Driven Programming with ExtendScript | Ozalto

HTH

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
Explorer ,
Mar 07, 2018 Mar 07, 2018

Is this JavaScript?!

It doesn't look familiar...

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
People's Champ ,
Mar 08, 2018 Mar 08, 2018

I think that what confuses you is that you may have used the InDesign own Dialog Class for building your UI while I am offering an UI based on ScriptUI (see ScriptUI for Dummies for more details).

But yes, it's Javascript, well ExtendScript.

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
Explorer ,
Mar 08, 2018 Mar 08, 2018
LATEST

You're right!!!

Thank you for telling me about this scriptUI, it is very handy, especially for creating floating Panels!!!

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