Subscribe Bookmark RSS Feed

Modal dialog scripting: would like to press Enter instead of Click OK

galactus3000

Contributor

Joined:

Nov 9, 2016

Modal dialog scripting: would like to press Enter instead of Click OK

I have a modal dialog script with [OK] and [Cancel] buttons where the pre-populated entry is most often accepted rather than typed over.

I would like to be able to press Enter to accept rather than clicking the OK button to accept.

Is there an easy way to do this?

 

My script right now is

 

New Window( "Enter Number",
<<Modal,
Text Box("Enter Number"),
variablebox = Number Edit Box( UsuallyTheRightNumber ),
Button Box( "OK"),
Button Box( "Cancel")
);

dt:height[i]=variablebox<<get;

 

Again, the script is working fine but having to mouse click OK instead of just pressing Enter is a major inconvenience.

 

Thanks

Charlie

 

1 ACCEPTED SOLUTION

Accepted Solutions
vince_faller

Super User

Joined:

Mar 17, 2015

Solution

Could also just make the function click the button for you.  This would be if you click the box then click something else as well (if the number has changed) though. May not be what you want.  

 

New Window( "Enter Number",
	<<Modal,
	Text Box( "Enter Number" ),
	variablebox = Number Edit Box( 14,  10,
		<<Set Function(
			Function({this}, 
				btn_ok << Click
			)
		)
	),
	btn_ok = Button Box( "OK", 
		x = variablebox << get;
	),
	Button Box( "Cancel" )
);

 

7 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Try this

Names Default To Here( 1 );

nw=New Window(
	"Enter Number",
	<<Modal,
	Text Box( "Enter Number" ),
	variablebox = Number Edit Box(
		,
		10,
		<<SetFunction(
			Function( {this}, /* put my value into my sibling's display */
				variableboxvalue = variablebox << get;
				nw << close window;
			)
		)
	)
);
dt:height[i] = variableboxvalue;
Jim
galactus3000

Contributor

Joined:

Nov 9, 2016

Just to confirm:

 
nw=New Window(
"Enter Number",
<<Modal,
Text Box( "Enter Number" ),
variablebox = Number Edit Box(
,
UsuallyTheRightNumber,
<<SetFunction(
Function( {this}, /* put my value into my sibling's display */
variableboxvalue = variablebox << get;
nw << close window;
)
)
)
);
dt:height[i] = variableboxvalue;

 

where the first argument is empty and the second argument is the number (actually a variable I called UsuallyTheRightNumber) that the text box defaults to.

Or does the number 10 have a special significance?

 

 

vince_faller

Super User

Joined:

Mar 17, 2015

Solution

Could also just make the function click the button for you.  This would be if you click the box then click something else as well (if the number has changed) though. May not be what you want.  

 

New Window( "Enter Number",
	<<Modal,
	Text Box( "Enter Number" ),
	variablebox = Number Edit Box( 14,  10,
		<<Set Function(
			Function({this}, 
				btn_ok << Click
			)
		)
	),
	btn_ok = Button Box( "OK", 
		x = variablebox << get;
	),
	Button Box( "Cancel" )
);

 

galactus3000

Contributor

Joined:

Nov 9, 2016

Thanks.

What are the significance of 14 and 10 here?

 

vince_faller

Super User

Joined:

Mar 17, 2015

14 is just the default number.  10 is the width of the box.  depending on version of JMP if you don't put in a width it does some funky stuff.  

galactus3000

Contributor

Joined:

Nov 9, 2016

thanks

 

txnelson

Super User

Joined:

Jun 22, 2012

Just to complete the education on this topic, the documentation on the format and functions of the Number Edit Box is available at:

     Help==>Scripting Index==>Number Edit Box

The description of the fields and elements that are available is there, plus actual examples that can be run that illustract how each of them work

Number Edit Box.PNG

Jim