cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Andyon98
Level II

How do I close a “New window”?

I have been trying to close new windows but am successful, for arguments sake, I tried x = New Window( *some code*);

Close(x);
x << Close();
x << Close;
x << Close Window();


Any help would be greatly appreciated

2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: How do I close a “New window”?

<< Close Window; or << Close Window(); should work

Names Default To Here(1);

nw = New Window("");
wait(2);
nw << Close Window();
-Jarmo

View solution in original post

pmroz
Super User

Re: How do I close a “New window”?

Here is a slightly more complicated example showing how to close a non-modal window with either the OK or Cancel buttons.

nw = new window("Test",
	textbox("Hello World"),
	panelbox("Actions",
		hlistbox(
			okb = button box("OK", << set icon("Go"),
				set script(
					show("Clicked OK");
					// Other OK actions here
					nw << close window();
				),
			),
			canb = button box("Cancel", << set icon("Stop"),
				set script(
					show("Clicked Cancel");
					nw << close window();
				),
			),
		)
	)
);

pmroz_0-1655383151938.png

 

View solution in original post

4 REPLIES 4
jthi
Super User

Re: How do I close a “New window”?

<< Close Window; or << Close Window(); should work

Names Default To Here(1);

nw = New Window("");
wait(2);
nw << Close Window();
-Jarmo
txnelson
Super User

Re: How do I close a “New window”?

For syntax questions such as you are asking, you can find your answers in the Scripting Index.

     Help=>Scripting Index

Jim
pmroz
Super User

Re: How do I close a “New window”?

Here is a slightly more complicated example showing how to close a non-modal window with either the OK or Cancel buttons.

nw = new window("Test",
	textbox("Hello World"),
	panelbox("Actions",
		hlistbox(
			okb = button box("OK", << set icon("Go"),
				set script(
					show("Clicked OK");
					// Other OK actions here
					nw << close window();
				),
			),
			canb = button box("Cancel", << set icon("Stop"),
				set script(
					show("Clicked Cancel");
					nw << close window();
				),
			),
		)
	)
);

pmroz_0-1655383151938.png

 

pmroz
Super User

Re: How do I close a “New window”?

Here's another wrinkle with regard to closing windows.  Let's say you have a dataset open and when the user clicks OK or Cancel there is an action to close the dataset.  But what if the user clicks the close window button (X in upper right)?  The on close() function takes care of it.  Here's an example:

// Build a display window for ftab_box
ftab_window = New Window("Frequency Tab", << on close(close(ftab_dataset, nosave)),
	H List Box(
		Button Box("Save to MSWord",
			ftab_output << Save MSWord("", Native);
		),
		Text Box( "   " ),
		Button Box( "Close this Window", 
					ftab_window << CloseWindow; 
//					close(ftab_dataset, nosave);	// This gets run by on close above
					),
	),
	ftab_output = vlistbox(
		outlinebox(ftab_title,
			ftab_box),
	),
);