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

How to show/hide group of buttons based on dropdown list selection

Engaged ,
Aug 17, 2021 Aug 17, 2021

Copy link to clipboard

Copied

I created some dialog box, and i have doubt is it posible to show/hide some part of dialog box based on dropdown list selection. For example, i want to hide whole panel1 if on dropdown listi is selected "Solution2"

var startRulerUnits = app.preferences.rulerUnits;  
app.preferences.rulerUnits = Units.CM;
var box = new Window('dialog', "EXAMPLE");
var b = ["Solution1", "Solution 2", "Solution 3"];  
for (var i = 0; i < b.length; i += 1) {  
b["_"+b[i]] = i;  
}
box.group7 = box.add('group', undefined );  
box.group7.orientation='row'; 
box.group7.alignment = 'right'; 
box.group7.text1 = box.group7.add('statictext', undefined, "List od solutions");
box.group7 = box.group7.add("dropdownlist", [25,40,160,60], b); 
box.panel1 = box.add('panel', undefined, "Test");
box.panel1.group41 = box.panel1.add('group', undefined ); 
box.panel1.group41.text1 = box.panel1.group41.add('statictext', undefined, "Buton1:");
var btn1 = box.panel1.group41.add('edittext', [25,40,10,60],"",{multiline:false, scrollable:false});
box.panel1.group41.text2 = box.panel1.group41.add('statictext', undefined, "");
box.panel1.group42 = box.panel1.add('group', undefined ); 
box.panel1.group42.orientation='row';  
box.panel1.group42.alignment = 'right';
box.panel1.group42.text1 = box.panel1.group42.add('statictext', undefined, "Button 2:");
var btn2 = box.panel1.group42.add('edittext', [25,40,10,60],"",{multiline:false, scrollable:false});
box.panel1.group42.text2 = box.panel1.group42.add('statictext', undefined, "");
box.panel1.group43 = box.panel1.add('group', undefined ); 
box.panel1.group43.orientation='row';  
box.panel1.group43.alignment = 'right';
box.panel1.group43.text1 = box.panel1.group43.add('statictext', undefined, "Button 3:");
var btn3 = box.panel1.group43.add('edittext', [25,40,10,60],"",{multiline:false, scrollable:false});
box.panel1.group43.text2 = box.panel1.group43.add('statictext', undefined, "");
box.panel1.group44 = box.panel1.add('group', undefined ); 
box.panel1.group44.orientation='row';  
box.panel1.group44.alignment = 'right';
box.panel1.group44.text1 = box.panel1.group44.add('statictext', undefined, "Button 4:");
var btn4 = box.panel1.group44.add('edittext', [25,40,10,60],"",{multiline:false, scrollable:false});
box.panel1.group44.text2 = box.panel1.group44.add('statictext', undefined, "");
box.panel1.group45 = box.panel1.add('group', undefined ); 
box.panel1.group45.orientation='row';  
box.panel1.group45.alignment = 'right';
var chck1 = box.panel1.group45.add("checkbox", undefined, "Not used");
var btnGroup = box.add ("group");
btnGroup.orientation = "row";
var btnOk = btnGroup.add("button", undefined, "OK");  
var btnCancel = btnGroup.add("button", undefined, "Cancel"); 
box.center();
btnOk.onClick = function() {  
box.close(1);
};  
btnCancel.onClick = function() {  
box.close(0);
}; 
box.show()

 

TOPICS
Actions and scripting , SDK

Views

87

Likes

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

LEGEND , Aug 17, 2021 Aug 17, 2021
box.group7.onChange = function() {box.panel1.visible = this.selection.text != 'Solution 2'}

Likes

Translate

Translate
LEGEND ,
Aug 17, 2021 Aug 17, 2021

Copy link to clipboard

Copied

box.group7.onChange = function() {box.panel1.visible = this.selection.text != 'Solution 2'}

Likes

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
Engaged ,
Aug 17, 2021 Aug 17, 2021

Copy link to clipboard

Copied

LATEST

Thanks @Kukurykus quickly and correct, as always! 

Likes

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