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

Button help

Engaged ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

Guys, how to make the callback of each button?

How to call a function for each button

Thanks

 

var dialog = new Window("dialog"); dialog.text = "Dialog";
dialog.orientation = "column"; 
dialog.alignChildren = ["center","top"]; 

array=["B1","B2","B3","B4",]

for (i = 0; i < array.length; i++) {   
    array[i];
    bt = dialog.add("button"); bt.text =array[i];          
}
 

dialog.show();

 

 

TOPICS
Actions and scripting

Views

249

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

People's Champ , Aug 11, 2022 Aug 11, 2022
var dialog = new Window("dialog"); dialog.text = "Dialog";
dialog.orientation = "column"; 
dialog.alignChildren = ["center","top"]; 

array=["B1","B2","B3","B4",]
array2=[f1,f2,f3,f4]


for (i = 0; i < array.length; i++) {   
    array[i];
    bt = dialog.add("button"); bt.text =array[i]; bt.onClick = array2[i];                   
}

dialog.show();

function f1() { alert(1); }
function f2() { alert(2); }
function f3() { alert(3); }
function f4() { alert(4); }

Votes

Translate

Translate
Adobe
People's Champ ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

var dialog = new Window("dialog"); dialog.text = "Dialog";
dialog.orientation = "column"; 
dialog.alignChildren = ["center","top"]; 

array=["B1","B2","B3","B4",]
array2=[f1,f2,f3,f4]


for (i = 0; i < array.length; i++) {   
    array[i];
    bt = dialog.add("button"); bt.text =array[i]; bt.onClick = array2[i];                   
}

dialog.show();

function f1() { alert(1); }
function f2() { alert(2); }
function f3() { alert(3); }
function f4() { alert(4); }

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
Engaged ,
Aug 12, 2022 Aug 12, 2022

Copy link to clipboard

Copied

LATEST

 Perfect @r-bin! Thank you so much for sharing your knowledge

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