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

Help Button

Participant ,
Feb 04, 2016 Feb 04, 2016

I am creating a small dialog panel

I would like to add a button with this function

you think you can do it?

this function

var aLevels = dPanel.add ("checkbox", undefined, "Apply auto levels");

if (app.documents.length > 0) {

  try {

  if (activeDocument.activeLayer.visible == true) {

  activeDocument.activeLayer.visible = false;

  } else {

  activeDocument.activeLayer.visible = true;

  }

  }

  catch (e) {}

}

TOPICS
Actions and scripting
475
Translate
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 ,
Feb 04, 2016 Feb 04, 2016

Do you want a button to click or a checkbox? You have a checkbox mentioned above. To have a button run a function you would use:

var dlg = new Window('dialog','help button');

dlg.helpButton = dlg.add('button',undefined,'Help Button');

dlg.helpButton.onClick = function(){

//your function code here

dlg.close()//if you want the dialog box to close

}

dlg.show()

Translate
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
Participant ,
Feb 04, 2016 Feb 04, 2016

I would need a checkbutton

which has the dual function to enable and disable the selected level.

Translate
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
Contributor ,
Feb 05, 2016 Feb 05, 2016

Guys no one has an answer to this problem that has placed gionnyp9672044

Translate
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 ,
Feb 07, 2016 Feb 07, 2016
LATEST

I'm still unclear about what exactly you want to do. a checkbox turns something on or off, which doesn't seem too good for the code you have listed above. If you want a button that turns a layer's viability on or off depending if that layer is visible or not then you can use code like this: add line 4 to your onClick function for a button.

var doc = activeDocument;

var layer = doc.activeLayer;

layer.visible = layer.visible == false

Translate
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