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

Multi button click

Participant ,
Mar 18, 2017 Mar 18, 2017

Copy link to clipboard

Copied

Why does not alert when the button at the top is clicked

win = new Window('dialog', 'Dialog Multi Button'); 

var grp2 = win.add('group');

grp2.orientation = 'row';

grp2.alignChildren = 'left';

grp2.spacing = 0;

var grp1 = win.add('group');

grp1.orientation = 'row';

grp1.alignChildren = 'left';

grp1.spacing = 0;

var myT = [];

for(var i = 'A'.charCodeAt(0); i <= 'E'.charCodeAt(0);  ++i) {

myT.push(String.fromCharCode(i));

}

var btns = []

for (var i = 0; i < myT.length; i++){

btns.push({c:grp1.add ("button", [0,0,150,50], myT)});

btns.c.graphics.font = "Arial:30";

}   

var btns2 = []

for (var i = 0; i < myT.length; i++){

btns2.push({d:grp2.add ("button", [0,0,150,50], myT)});

btns2.d.graphics.font = "Arial:15";

btns2.d.onClick = function() {win.close(i)} 

}        

win.addEventListener ( 'keydown', onKeyPress ); 

win.center() 

var myDlg = win.show() 

function onKeyPress (evt) { 

for (var i = 0; i < btns.length; i++){

  if (evt.keyName==btns.c.text) { 

  win.close(i) 

  }; 

}

}

for (var i = 0; i < myT.length; i++){

if(myDlg == i){ 

alert(myT);

}

}

TOPICS
Scripting

Views

200

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
People's Champ ,
Mar 18, 2017 Mar 18, 2017

Copy link to clipboard

Copied

LATEST

I don't have doc at hand but I think the return codes range isn't that extended.

An alternative would be to "bind" a property to the window object itself.

win.code = i;

win.close(1);

if ( win.show()==1 ) {

     alert( win.code);

}

FWIW

Loic

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