Skip to main content
Inspiring
November 13, 2014
Answered

Photoshop Script - access UI layout within variable?

  • November 13, 2014
  • 1 reply
  • 431 views

Hi there,

I've got the following variable as a UI layout of a window, I am trying to access btn_one button, but with no success.

var w = new Window("dialog {  \

    margins: 15, \

        btn_one: Button { \

            text: 'Button', \

            size: [100,25], \

            alignment:['right', 'center'] \

        }, \

    }");

Any help on achieving this? I need tried the following, it doesn't work.

btn_one.onClick = function(){

}

Thanks

This topic has been closed for replies.
Correct answer xbytor2

In your case, this may work:

   w.btn_one.onClick();

Not sure because I never build windows that way. I create the Window first then add the button on a separate line.

1 reply

xbytor2Correct answer
Inspiring
November 13, 2014

In your case, this may work:

   w.btn_one.onClick();

Not sure because I never build windows that way. I create the Window first then add the button on a separate line.

gespinhaAuthor
Inspiring
November 13, 2014

w.btn_one.onClick(); doesn't work

I have tried something like this previously:

cal.add("button", [165,40,275,60], "stuff");

But how do I add the settings, like on the example above, on this model? size, alignment and all others?

cal.add("button", [165,40,275,60], "stuff");cal.add("button", [165,40,275,60], "stuff");cal.add("button", [165,40,275,60], "stuff");cal.add("button", [165,40,275,60], "stuff");cal.add("button", [165,40,275,60], "stuff");cal.add("button", [165,40,275,60], "stuff");

Inspiring
November 13, 2014

Check the docs. They have a decent section on automatic widget layout. I've never used it because the layout algorithm would change in unexpected ways as new versions of PS were released. With manual layout, I am able to precisely control the layout so I have UI code that works predictably as far back as CS and CS2. Things may have stabilized with the automatic layout over the past few revs and if you don't need to support older versions of PS you should definitely try it out.