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.
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();
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.
That is what I thought. The code you posted from the guide does work in Photoshop CS4. It also works in some of the other CS5 apps like Bridge and InDesign.
I don't know if it is a bug or an intended change, but as I said there are many features of ScriptUI do not work in Photoshop CS5. Mouseover events and multi-column listbox are othere examples of features that don't work in CS5.
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.
FWIW, I tried the autolayout manager in early CS releases. Unfortunately, it tended to behave differently from rev to rev. Since I needed my scripts to run across multiple versions of PS, this was not an alternative.
Lately, I've had to do a bunch of localization work and wound up having to make my widgets dynamically resize depending on the locale. Autolayout would have helped out a lot here.
Actually Paul, it doesn't look like its the bounds that make your code work. Just changing the P in Panel to lowercase p does the trick:
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'} } \
}";
That must be a bug, no?
North America
Europe, Middle East and Africa
Asia Pacific