Copy link to clipboard
Copied
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) {}
}
Copy link to clipboard
Copied
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()
Copy link to clipboard
Copied
I would need a checkbutton
which has the dual function to enable and disable the selected level.
Copy link to clipboard
Copied
Guys no one has an answer to this problem that has placed gionnyp9672044
Copy link to clipboard
Copied
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
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more