Skip to main content
Inspiring
December 7, 2009
Question

Panel position and size

  • December 7, 2009
  • 2 replies
  • 616 views

Is there a way to set a panel's x/y position and size using PS scripting?  If someone could point me to some documentation on this, that would be hugely appreciated!

This topic has been closed for replies.

2 replies

PhilterAuthor
Inspiring
December 7, 2009

This is perfect.  Thanks for the example Michael!  I'll give this a try.

Inspiring
December 7, 2009

If you are asking about the built-in panels, no you can not move or size them with scripting.

PhilterAuthor
Inspiring
December 7, 2009

Thanks for your response Michael.

Actually, to be more specific, I'm building a Flash based panel to use with Photoshop.  Not sure if this qualifies as a "built-in" panel as you mention.

What I'm looking to do is have the panel resize itself when a button within the panel is pressed.  Also, I'd like to be able to position the panel to a specific x/y location when it is opened.

Inspiring
December 7, 2009

I don't think you can set the position of a custom panel. It seems to open where ever it was last closed. But you can set the size.

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="init()"
     paddingLeft="0" paddingBottom="0" paddingRight="0" paddingTop="0"
     verticalScrollPolicy="off" horizontalScrollPolicy="off"
     horizontalGap="0" verticalGap="1">
     <mx:Script>
          <![CDATA[
               import com.adobe.csxs.core.CSXSInterface;
               import com.adobe.csxs.events.*;
               import com.adobe.csxs.types.*;
               
               private function getGeometry():WindowGeometry {
                    var panel_X:Number = 100;
                    var panel_Y:Number = 100;
                    var panel_W:Number = windowsizebox.width + 15;
                    var panel_H:Number = windowsizebox.height + 20;
                    var windowsize:WindowGeometry = new WindowGeometry(panel_X,panel_Y,panel_W,panel_H);
                    return windowsize;
               }
               private function setSize():void{
                    var csxs:CSXSInterface = CSXSInterface.getInstance(); 
                    csxs.requestStateChange(StateChangeEvent.WINDOW_RESIZE, getGeometry());
               }
               /**
                    Function:          init
                    Description:     Initialize the panel
                                        
               */
               public function init():void{
                    try{// for skinning
                         var result:SyncRequestResult = CSXSInterface.instance.getHostEnvironment();
                         var hostData:HostEnvironment = result.data;
                         var skinInfo:AppSkinInfo = hostData.appSkinInfo;
                         var defaultColor:String = skinInfo.panelBackgroundColor.color.rgb;
                         this.setStyle("backgroundGradientColors", [defaultColor, defaultColor]);
                         this.setStyle("fontFamily", skinInfo.baseFontFamily);
                         this.setStyle("fontSize", skinInfo.baseFontSize);          
                    }catch (errObject:Error) {}
               }
          
          ]]>
     </mx:Script>
     <mx:VBox x="10" y="10" id="windowsizebox"  height="100" width="100">
          <mx:Button label="Button" click="setSize();"/>
     </mx:VBox>

</mx:Application>