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

Help With ScriptUI

Contributor ,
Feb 21, 2020 Feb 21, 2020

I have a simple Dialog with a Button.

When the button pressed, I want it to close the Dialog and open another one.

This works but when the second Dialog is opened, it doesn't have focus.


Question:

Is there a way to make this second Dialog have focus after the code has run ?

 

For the Buton onClick I am using

button2.onClick = function(){
  dialog.close();
  ShowMe(); // call this function to open 2nd Dialog
}

 

and the contents of the ShowMe function is

function ShowMe(){
    var w = new Window("dialog"); 
    w.text = "Dialog"; 
    w.orientation = "column"; 
    w.alignChildren = ["center","top"]; 
    w.spacing = 10; 
    w.margins = 16;   

var bnt_close = w.add("button", undefined, undefined, {name: "bnt_close"}); 
    bnt_close.text = "Close"; 
    bnt_close.onClick = function(){w.close()};

w.show();

}

 

ian

TOPICS
Actions and scripting
1.6K
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

correct answers 1 Correct answer

Mentor , Feb 21, 2020 Feb 21, 2020

call function ShowMe() outside function of first dialog

 

ShowMeFirst()
ShowMeSecond()

function ShowMeFirst(){
    var w = new Window("dialog"); 
    w.text = "Dialog"; 
    w.orientation = "column"; 
    w.alignChildren = ["center","top"]; 
    w.spacing = 10; 
    w.margins = 16;   

var bnt_close = w.add("button", undefined, undefined, {name: "bnt_close"}); 
    bnt_close.text = "Close"; 
    bnt_close.onClick = function(){w.close()};

w.show();

}

function ShowMeSecond() {
    var w = new Wi
...
Translate
Adobe
Mentor ,
Feb 21, 2020 Feb 21, 2020

call function ShowMe() outside function of first dialog

 

ShowMeFirst()
ShowMeSecond()

function ShowMeFirst(){
    var w = new Window("dialog"); 
    w.text = "Dialog"; 
    w.orientation = "column"; 
    w.alignChildren = ["center","top"]; 
    w.spacing = 10; 
    w.margins = 16;   

var bnt_close = w.add("button", undefined, undefined, {name: "bnt_close"}); 
    bnt_close.text = "Close"; 
    bnt_close.onClick = function(){w.close()};

w.show();

}

function ShowMeSecond() {
    var w = new Window("dialog"); 
    w.text = "Dialog"; 
    w.orientation = "column"; 
    w.alignChildren = ["center","top"]; 
    w.spacing = 10; 
    w.margins = 16;   

var bnt_close = w.add("button", undefined, undefined, {name: "bnt_close"}); 
    bnt_close.text = "Close"; 
    bnt_close.onClick = function(){w.close()};

w.show();

}

 

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
Contributor ,
Feb 21, 2020 Feb 21, 2020

Thank you.

So basically, when the button is pressed it closes the Dialog and then carries on to run the ShowMeSecond() function

 

Ian

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
Mentor ,
Feb 21, 2020 Feb 21, 2020

also you can return numeric arguments, if needed, or use preserved names to buttons ({name: "ok"} returns 1, {name: "cancel"} returns 2 )

 

if (ShowMeFirst().show() == 1) {ShowMeSecond()}

function ShowMeFirst(){
    var w = new Window("dialog"); 
    w.text = "Dialog"; 
    w.orientation = "column"; 
    w.alignChildren = ["center","top"]; 
    w.spacing = 10; 
    w.margins = 16;   

var bnt_close = w.add("button", undefined, undefined, {name: "bnt_close"}); 
    bnt_close.text = "Close"; 
    bnt_close.onClick = function(){w.close(1)};

 return w
}

function ShowMeSecond() {
    var w = new Window("dialog"); 
    w.text = "Dialog"; 
    w.orientation = "column"; 
    w.alignChildren = ["center","top"]; 
    w.spacing = 10; 
    w.margins = 16;   

var bnt_close = w.add("button", undefined, undefined, {name: "bnt_close"}); 
    bnt_close.text = "Close"; 
    bnt_close.onClick = function(){w.close()};

w.show();

}

 

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
LEGEND ,
Feb 21, 2020 Feb 21, 2020

 

 

bnt_close = w.add("button", undefined, undefined, {name: "bnt_close"})
bnt_close.text = "Close"; bnt_close.onClick = function(){w.close(1)}

 

you can change to:

 

bnt_close = w.add('button', undefined, 'Close', {name: 'ok'})

 

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
LEGEND ,
Feb 21, 2020 Feb 21, 2020
LATEST

w.active = true;

 

I see this more commonly on the Mac, where a new window doesn't have focus.

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