IconButton

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

larsen67

IconButton

Post by larsen67 »

In ScriptUI is it possible to make these stay pressed? I have an array of these and I want each one that is selected to look like its stayed down… I know how to stick checkboxes next to them but I was hoping to avoid that? This is the basic visual idea… Where I captured clicking just one…


Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

IconButton

Post by Mike Hale »

How are you defining the image? I think you would need to use a ScriptUIImage object and use at least the normal and pressed arguments.

Either that or use the button's onClick handler to change out the icon.
larsen67

IconButton

Post by larsen67 »

Mike, it looks like what I would like falls between 2 UI elements behavior… How typical is that? I like Icon buttons for mouse over darken state and the fact that you can use tab (R>>L) shift+tab (L>>R) and space bar select… I have onClick functions for each of these… What I was hoping to do was maybe brush over the Icon button's graphic with 20% black so I would not need multi state images… I will have to dig about further… I have also tried using 2 images one for each state but then the issue is I can remove(0); but how do you position the replacement. It looks like I would have to rebuild the whole dialog and that makes not sense… The idea of the example was that the user could select any or all the buttons… I should go read the manuals again… Seem to spend have my dammed life in PDFs… It may be what I want is…

newImage()
ScriptUI.newImage ( normal, disabled, pressed, rollover );

But there appears to be no example…
Mike Hale

IconButton

Post by Mike Hale »

What version of Photoshop are you using? The code below works in CS5. There is a difference in the normal and pressed state even though it uses one image per button. The difference may not be as much as you like though.

Code: Select allcreateDialog = function ( ) {
   var dlg = new Window( 'dialog', 'Iconbutton Example Script' );
   var i = ScriptUI.newImage( new File('/c/t.png'));
   dlg.iBtn = dlg.add ('iconbutton' , undefined,  i,{style:'button',toggle:true});
   var i1 = ScriptUI.newImage( new File('/c/t.png'));
   dlg.i1Btn = dlg.add ('iconbutton' , undefined,  i1,{style:'toolbutton',toggle:true});
   dlg.btnPnl = dlg.add( 'panel', undefined );
   dlg.btnPnl.orientation = "row";
   dlg.btnPnl.alignment = "right";
   dlg.btnPnl.preferredSize [ 80, 80 ]
   dlg.btnPnl.okBtn = dlg.btnPnl.add( 'button', undefined, 'Ok', { name:'ok' });
   dlg.btnPnl.cancelBtn = dlg.btnPnl.add( 'button', undefined, 'Cancel', { name:'cancel' });
   return dlg;
};
initializeDialog = function( w ) {
 }

runDialog = function( w ) {
   return w.show( );
};
var win = createDialog();
initializeDialog(win);
runDialog(win);

For ScriptUI.newImage ( normal, disabled, pressed, rollover ); each of the arguments is a file object for the image in that state. Something like
Code: Select allvar buttonImage = ScriptUI.newImage ( File('~/desktop/psd_n.png'),  File('~/desktop/psd_d.png'),  File('~/desktop/psd_p.png'), File('~/desktop/psd_r.png') );