Copy link to clipboard
Copied
I find this interesting post
I would like to know how to enter commands
.onClick = function () {
Copy link to clipboard
Copied
Various UI controls require different functions. The onClick function is for things that are actually clicked like buttons, radio buttons, and check boxes. You basically put the function within the code that defines your UI, with the name of the control before the .onClick, followed by a pair of parenthesis, then a pair of braces that contain the code you want to run.
Copy link to clipboard
Copied
Sorry how I could make it work.
Copy link to clipboard
Copied
Here is a very simpe code to show how onClick is used:
var dlg = new Window('dialog','onClick test');
dlg.btn = dlg.add('button',undefined,'Click Me');
dlg.btn.onClick = function(){alert('You clicked the button')}
dlg.show();
Copy link to clipboard
Copied
Chuck thanks this I knew it
Do not know how to run onclick with listbox?
Or an alternative function?
Copy link to clipboard
Copied
Listboxes don't use onClick. They use onChange:
#target photoshop
var dlg = new Window('dialog','Listbox');
var list = ['one','two','three'];
dlg.listBx = dlg.add('listbox',undefined,list);
dlg.listBx.onChange = function(){
alert(dlg.listBx.selection.text)
}
dlg.show()