Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

scriptui multiple buttons action

$
0
0

I want to create a dialog consisting of multiple buttons. As a result I want value which button was pressed by user.

 

The script (shortened to problematic part):

 

// I'm looping through elements on layer 'warstwa' from kolorStart to kolorStop, 'k' is used for number buttons                    for (i = kolorStart, k = 0; i <= kolorStop; k++, i++) {                              myButton[k] = myButtonGroup.add ("button", undefined, warstwa.pageItems[i].contents);                              myButton[k].label = warstwa.pageItems[i].contents;                              myButton[k].onClick = function () { wybranyKolor = myButton[k].label; myWindow.close(); }                    }

The result:

skrypt2.gif

 

but buttons don't work, wybranyKolor returning 'undefined'. If I change "wybranyKolor =  myButton[k].label" to "wybranyKolor =  myButton[k-1].label" I get proper answer but it is the same for all buttons so it looks that all buttons have the same acion assigned. How to get each button to has unique name which can be passed to variable?

 

Propably I can achive the same with radio buttons' list but with buttons it is one click less for the user.


Viewing all articles
Browse latest Browse all 12845

Trending Articles