cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
matth1
Level IV

Buttons to close modal dialog

As I understand it, only a maximum of two buttons can close a modal dialog: "OK" and "Cancel" (or other similarly named buttons).

What I'd like is to have another button which does something (say, set a variable), then closes the dialog as if I'd pressed the "OK" button. Something like this:

 

Names Default To Here( 1 );
a=0;
nw = New Window( "Demo",
	<<modal,
	<<returnresult,
	Text Box( "A modal dialog" ),
	Button Box( "Do something different", a = 1 ), // I want this to close the dialog!
	H List Box( Button Box( "OK" ), Button Box( "Cancel" ) )
);
Show( nw, a );

Is there any way of doing this? I tried including "nw << close window" in the button script but that didn't work.

I could use a text edit box, or a check box, or many other options to set a=1 before pressing "OK", but all of those are additional clicks.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Buttons to close modal dialog

You can make that button press OK button using << Click(1)

Names Default To Here(1);
a = 0;
nw = New Window("Demo",
	<<modal,
	<<returnresult,
	Text Box("A modal dialog"),
	Button Box("Do something different",
		a = 1;
		ok_btn << Click(1);
	), // I want this to close the dialog!
	H List Box(ok_btn = Button Box("OK"), Button Box("Cancel"))
);
Show(nw, a);
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Buttons to close modal dialog

You can make that button press OK button using << Click(1)

Names Default To Here(1);
a = 0;
nw = New Window("Demo",
	<<modal,
	<<returnresult,
	Text Box("A modal dialog"),
	Button Box("Do something different",
		a = 1;
		ok_btn << Click(1);
	), // I want this to close the dialog!
	H List Box(ok_btn = Button Box("OK"), Button Box("Cancel"))
);
Show(nw, a);
-Jarmo
matth1
Level IV

Re: Buttons to close modal dialog

Thank you, nice solution! I was unaware that Click() existed - one to remember.

Recommended Articles