Skip navigation
Currently Being Moderated

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

Jan 28, 2012 5:23 AM

Tags: #photoshop #javascript #string #guide #resource #window #dialog #tools #ui

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.

 
Replies
  • Currently Being Moderated
    Jan 28, 2012 6:23 AM   in reply to Reimund T

    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();
    
    
     
    |
    Mark as:
  • Currently Being Moderated
    Jan 28, 2012 7:20 AM   in reply to Reimund T

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 28, 2012 9:38 AM   in reply to Reimund T

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

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 28, 2012 9:39 AM   in reply to Reimund T

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 28, 2012 10:00 AM   in reply to Reimund T

    Sorry but it doesn't like undefined, I gave it a try but it didn't work.

    I am sure auto layout would be easier in the long run

     
    |
    Mark as:
  • JJMack
    3,425 posts
    Jan 9, 2006
    Currently Being Moderated
    Jan 28, 2012 1:37 PM   in reply to Reimund T

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 28, 2012 3:10 PM   in reply to Paul Riggott

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 29, 2012 3:08 AM   in reply to Reimund T

    That is interesting! The first thing I tried was to put the widgets into lower case, but it now seems that Button must be in uppercase. I would say that is a bug.

    I keep all my widgets in lower case so that they are compatable across the versions (Auto layout)

     

    Nice find!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points