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
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" )
);
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;
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?
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" )
);
Thanks.
What are the significance of 14 and 10 here?
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.
thanks
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