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

Help With ScriptUI

Participant ,
Feb 21, 2020 Feb 21, 2020

Copy link to clipboard

Copied

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

Views

1.2K

Translate

Translate

Report

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

Guide , 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
...

Votes

Translate

Translate
Adobe
Guide ,
Feb 21, 2020 Feb 21, 2020

Copy link to clipboard

Copied

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();

}

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Thank you.

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

 

Ian

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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();

}

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

 

 

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'})

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

w.active = true;

 

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

Votes

Translate

Translate

Report

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