Photoshop CS JS Adjust User Interface Panel size

Photoshop Script Snippets - Note: Full Scripts go in the Photoshop Scripts Forum

Moderators: Tom, Kukurykus

Larry Ligon

Photoshop CS JS Adjust User Interface Panel size

Post by Larry Ligon »

Someone asked how to do this on the adobe.photoshop.scripting forum. Here is my solution. It uses a scroll bar to adjust a panel size. You may or may not find it useful.

The dlg.msgPnl.hide() and dlg.msgPnl.show() are needed to erase the redraw artifacts. Comment out these two lines to see what I mean.

Save in a file named UI Panel resize.js

Code: Select all// Resize panel

var WindowPositionX = 100;
var WindowPositionY = 100;

var WindowWidth = 500;
var WindowHeight = 320;

var PanelPositionX =  20;
var PanelPositionY =  20;

var PanelWidth =  100;
var PanelHeight =  50;

//Create dialog box

var bounds = {x:WindowPositionX ,y:WindowPositionX ,
              width:WindowWidth ,height:WindowHeight };

var dlg = new Window('dialog', 'New Panel Resize',bounds );

var uiButtonClose = "Close";

var bounds = {x:380,y:30,width:50 ,height:20 };
dlg.btnClose = dlg.add("button",bounds ,uiButtonClose );
dlg.btnClose.onClick = function() { this.parent.close(0); };

var bounds = {x:PanelPositionX ,y:PanelPositionY ,
              width:PanelWidth ,height:PanelHeight };
dlg.msgPnl = dlg.add('panel',bounds ,'New Panel');

var bounds = {x:25,y:280,width:350 ,height:20 };
dlg.widthScrl = dlg.add('scrollbar',bounds,0,0,150);

//Change the height of the panel using the scroll bar value
dlg.widthScrl.onChange =
    function () {this.parent.msgPnl.bounds =
                {x:PanelPositionX,y:PanelPositionY,width:PanelWidth ,
                 height:PanelHeight + Math.round(this.parent.widthScrl.value)};
                 dlg.msgPnl.hide();
                 dlg.msgPnl.show();};

dlg.center();
dlg.show();