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
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
...
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();
}
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
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();
}
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'})
Copy link to clipboard
Copied
w.active = true;
I see this more commonly on the Mac, where a new window doesn't have focus.