cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
galactus3000
Level IV

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

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

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

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

 

Vince Faller - Predictum

View solution in original post

7 REPLIES 7
txnelson
Super User

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

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
Level IV

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

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

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

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

 

Vince Faller - Predictum
galactus3000
Level IV

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

Thanks.

What are the significance of 14 and 10 here?

 

vince_faller
Super User (Alumni)

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

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.  

Vince Faller - Predictum
galactus3000
Level IV

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

thanks

 

txnelson
Super User

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

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