Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[ScriptUI] Position of Window (dialog)?

Guest
Aug 06, 2009 Aug 06, 2009

Even when I think it's not possible I'm curious if I'm right:

Is there a way to set the location of a new window depending on the current selection?

Why?

... I want to spread the zoom to the page and want to make sure the dialog never hides the selection.

H.

TOPICS
Scripting
3.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 06, 2009 Aug 06, 2009

var p = new Window( "palette", "Show Me" );

p.add( "statictext", undefined, "How to move a window" );

// frameLocation is set by an array [ x, y ]

p.frameLocation = [ 250, 100 ];

p.show();

That'll set the window location. Now to figure out where it goes, you'll need to look at window.bounds and selection[ index ].geometricBounds to figure out how not to cover the selection.

Bob

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 12, 2009 Aug 12, 2009

While its possible to figure that the top left corner shouldn't cover the text, its not possible to figure what the width and height of the dialog is going to be after Adobe's layout engine lays out dialog. because the layout is only complete when window is shown, and when dialog is shown it's modal not giving the scripter the opportunity to move it.

Tell me if I'm wrong, but this was the result of my testing.

Steven

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 12, 2009 Aug 12, 2009

Check the Window.onShow() callback. While I don't have the time to test it at the moment, I believe the full geometry is ready during that callback, and you can make modifications to the layout and position.

I'll check it tomorrow; but, I'm fairly certain about this.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 13, 2009 Aug 13, 2009
LATEST

Here's a sample. Note that the window is created with the layout manager and is centered just prior to being shown.

The onShow handler moves it near the top left corner, and makes it bigger.

makeDialog = function() {

var d = new Window( "dialog", "Wow" );

d.add( "statictext", undefined, "Some text" );

var g = d.add( "group" );

g.alignChildren = ["right", "bottom" ];

d.okBtn = g.add( "button", undefined, "OK" );

d.canBtn = g.add( "button", undefined, "Cancel" );

d.okBtn.onClick = function() {

this.window.close( 1 );

}

d.canBtn.onClick = function() {

this.window.close( 2 );

}

d.onShow = function() {

$.writeln( "frameSize: " + this.frameSize );

this.frameLocation = [100,100];

this.size = [300, 200];

}

d.center();

d.show();

}

makeDialog();

Bob

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines