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

Any way to trigger OK button in modal window through script (i.e. when pressing Enter key in Text Edit Box)?

I have a modal window that asks user for text input using Text Edit Box.

For better user experience I'd like to make it so that when user hits Enter after typing in the input, it would be the same as user clicking OK button. Is there a way to do this?

win = New Window( "Text window",
<<Modal,
<<Return Result,
Text Box( "Type in your input" ),
textbox = Text Edit Box(  <<Set script(/*Some script here to hit OK button when Enter is pressed */) ),
Button Box( "OK" ),
Button Box( "Cancel" )
);
2 ACCEPTED SOLUTIONS

Accepted Solutions
miguello
Level VI

Re: Any way to trigger OK button in modal window through script (i.e. when pressing Enter key in Text Edit Box)?

I got this one!

win = New Window( "Text window",
<<Modal,
<<Return Result,
Text Box( "Type in your input" ),
textbox = Text Edit Box(  <<Set script(okbutton << Click()) ),
okbutton = Button Box( "OK" ),
Button Box( "Cancel" )
);

 

View solution in original post

jthi
Super User

Re: Any way to trigger OK button in modal window through script (i.e. when pressing Enter key in Text Edit Box)?

You could use something like

 

<<Set Function(Function({this}, (this << sib) << Click()))

but do note that this will also trigger if user clicks outside the text edit box.

 

 

View more...
Names Default To Here(1);

win = New Window("Text window",
	<<Modal,
	<<Return Result,
	Text Box("Type in your input"),
	textbox = Text Edit Box("", << Set Function(function({this},
		(this << sib) << Click()
	))),
	Button Box("OK"),
	Button Box("Cancel")
);

 

-Jarmo

View solution in original post

2 REPLIES 2
miguello
Level VI

Re: Any way to trigger OK button in modal window through script (i.e. when pressing Enter key in Text Edit Box)?

I got this one!

win = New Window( "Text window",
<<Modal,
<<Return Result,
Text Box( "Type in your input" ),
textbox = Text Edit Box(  <<Set script(okbutton << Click()) ),
okbutton = Button Box( "OK" ),
Button Box( "Cancel" )
);

 

jthi
Super User

Re: Any way to trigger OK button in modal window through script (i.e. when pressing Enter key in Text Edit Box)?

You could use something like

 

<<Set Function(Function({this}, (this << sib) << Click()))

but do note that this will also trigger if user clicks outside the text edit box.

 

 

View more...
Names Default To Here(1);

win = New Window("Text window",
	<<Modal,
	<<Return Result,
	Text Box("Type in your input"),
	textbox = Text Edit Box("", << Set Function(function({this},
		(this << sib) << Click()
	))),
	Button Box("OK"),
	Button Box("Cancel")
);

 

-Jarmo