Skip to main content
Known Participant
February 4, 2016
Question

Help Button

  • February 4, 2016
  • 2 replies
  • 441 views

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) {}

}

This topic has been closed for replies.

2 replies

Chuck Uebele
Community Expert
Community Expert
February 7, 2016

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

Chuck Uebele
Community Expert
Community Expert
February 4, 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()

Known Participant
February 4, 2016

I would need a checkbutton

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

tssee
Inspiring
February 5, 2016

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