Skip to main content
Known Participant
January 28, 2012
Question

Adding elements to a Dialog after it's been created using a resource string

  • January 28, 2012
  • 3 replies
  • 1455 views

I can add elements using add but not with a resource string.

The following works in ExtendScript Toolkit but not in Photoshop. Any idea why?

var window_res = "dialog { \

     orientation: 'row', \

     alignChildren: 'top', \

     preferredSize: [500, 500], \

}";

var btnPnlResource = "Panel { \

     orientation:'row', \

     text: 'Build it', \

     testBtn: Button { text:'Test' }, \

     buildBtn: Button { text:'Build', properties:{name:'ok'} }, \

     cancelBtn: Button { text:'Cancel', properties:{name:'cancel'} } \

}";

var w = new Window(window_res, 'Testing');

w.panel = w.add(btnPnlResource);

w.show();

The error I'm getting is Server Interface error "

As a side note: I copied the code from Javascript Tools Guide but I had to remove ""btnPnl: " from the beginning of the btnPnlResource string. Otherwise you get "btnPnl: is unknown or invalid in this context" error.

This topic has been closed for replies.

3 replies

JJMack
Community Expert
Community Expert
January 28, 2012

The most dynamic Photoshop Script Dialoig I have ever seen is the one X programed for the Plug-in Script "Image Processor Pro". Download it from Russell Brown's web site and install it.  You will see it under menu File>Automate>Image Processor Pro.  You can dynamicly add and delete Tabs to and from the center section of the dialog and even save added tabs configuration for use in the future.   Its done using and writeing XML configuration files.

JJMack
Inspiring
January 28, 2012

Are you using CS5? A lot of ScriptUI code that worked in CS4 or earlier vesions don't work in Photoshop CS5 but do in ExtendScript Toolkit 3.

Like Paul, I don't use resource string to create a dialog. Seems to me that if you are doing to use autolayout, using resource string makes it much harder to edit.

Reimund TAuthor
Known Participant
January 28, 2012

Mike, yes, I'm using CS5.

Paul, where would those bounds go you mean?

I put a lot of effort rewriting all of my UI code to a string resource so it hurts my soul to go back :|

Paul Riggott
Inspiring
January 28, 2012

The bounds are as per the example above Left, Top, Right, Bottom and they are relative to the window/panel.

Paul Riggott
Inspiring
January 28, 2012

I have given up using resource string as they get too complicated, I think the problem is that it would require bounds ....

var window_res = "dialog { \
     orientation: 'row', \
     alignChildren: 'top', \
     preferredSize: [500, 500], \
}";

var btnPnlResource =
   "panel { text: 'Build it', bounds:[15,330,365,375], \
      testBtn: Button { text:'Test', \
         bounds:[15,15,115,35] }, \
      buildBtn: Button { text:'Build',\
         bounds:[125,15,225,35], \
      properties:{name:'ok'} }, \
      cancelBtn: Button { text:'Cancel',\
         bounds:[235,15,335,35], \
      properties:{name:'cancel'} } \
   }";
dlg = new Window(window_res);
dlg.btnPnl = dlg.add(btnPnlResource);
dlg.show();