Using Javascript function parameters with onClick in photoshop dialog not working -


i've got script here (it's alot, sorry):

    var dlg = new window('dialog', 'templates',[1100,540,1465,720]);     dlg.btnpnl = dlg.add('panel', [20,15,345,155], 'please select template:');     dlg.btnpnl.shoes = dlg.btnpnl.add('button', [20,55,300,45], 'shoes, hats , belts', {name:'ok'});     dlg.btnpnl.bags = dlg.btnpnl.add('button', [20,85,300,45], 'bags , pouches', {name:'ok'});     dlg.btnpnl.shoes.onclick = extendcanvas(0.035, 1.035)     dlg.btnpnl.bags.onclick = extendcanvas(0.221, 1.221)     dlg.show();  function extendcanvas(negative, positive) {      #target photoshop  var doc = activedocument; var docwidth = activedocument.width; var docheight = activedocument.height; var docname = activedocument.name; var guides = activedocument.guides;  // if width longer height, extend height  if(docheight/ docwidth < 1.044) {      app.preferences.rulerunits = units.pixels      app.preferences.typeunits = typeunits.pixels      var stepone = docwidth * 1.044;     var steptwo = stepone * negative; // negative     var stepthree = stepone - steptwo;     var newheight = stepthree      doc.resizecanvas(null, unitvalue(stepthree, "px"), anchorposition.bottomcenter)     doc.guides.add(direction.horizontal, stepthree)     doc.resizecanvas(null, unitvalue(stepone, "px"), anchorposition.topcenter)     doaction('[white layer & move]','line action')   // if height longer width, extend width          } else if(docwidth/docheight < 0.957) {         app.preferences.rulerunits = units.pixels         tosubtract = docheight * negative; // negative         newheight = docheight - tosubtract;          app.preferences.rulerunits = units.pixels          app.preferences.typeunits = typeunits.pixels               doc.resizecanvas(unitvalue(docheight * 0.957, "px"), null, anchorposition.bottomcenter)         doc.guides.add(direction.horizontal, docheight)          var docwidth = doc.width;         var newheight = docheight * positive; //positive         var newwidth = docwidth * positive; //positive          doc.resizecanvas(unitvalue(newwidth, "px"), null, anchorposition.topcenter)         doc.resizecanvas(null, unitvalue(newheight, "px"), anchorposition.topcenter)         doaction('[white layer & move]','line action')       }   dlg.close();  } 

and works great when don't have 1 function extendcanvas parameters , instead have 2 separate functions both shoes , bags , each onclick calls them. reason though, when consolidate them 1 , add parameters function in onclick, when run script ignores dlg (it doesn't display) , runs function instead (incorrectly too, final canvas size on off).

i'm baffled , appreciate help.

thanks in advance!

add click handlers this:

    dlg.btnpnl.shoes.onclick = function() {extendcanvas(0.035, 1.035);}; 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -