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

How to use onClick

Advocate ,
Aug 03, 2017 Aug 03, 2017

Copy link to clipboard

Copied

I find this interesting post

I would like to know how to enter commands

.onClick = function () {

TOPICS
Actions and scripting

Views

2.0K

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
Adobe
Community Expert ,
Aug 03, 2017 Aug 03, 2017

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.

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
Advocate ,
Aug 03, 2017 Aug 03, 2017

Copy link to clipboard

Copied

Sorry how I could make it work.

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
Community Expert ,
Aug 03, 2017 Aug 03, 2017

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();

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
Advocate ,
Aug 03, 2017 Aug 03, 2017

Copy link to clipboard

Copied

Chuck thanks this I knew it

Do not know how to run onclick with listbox?

Or an alternative function?

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
Community Expert ,
Aug 03, 2017 Aug 03, 2017

Copy link to clipboard

Copied

LATEST

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()

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