Game Development Community

Capturing Enter key for GuiTextEditCtrl

by Bryce Bangerter · in Torque Game Builder · 07/17/2006 (10:20 pm) · 1 replies

Using a GuiTextEditCtrl how can I capture the enter key to trigger a function call? Basically I've got a dialog box with a single text edit control on it. I want to have pressing enter call the same function my OK button calls.

#1
07/17/2006 (11:12 pm)
If you set the altCommand variable in the GuiTextEditCtrl, it will execute that whenever the Return key or Numpad Enter is pressed.

For example:
new GuiTextEditCtrl(NameInput) {
  // blah blah blah goes here
  altCommand = "testAndSetName();";
};

You can also set this in the GUI editor (there is a field for it called AltCommand). Don't forget to put a semi-colon at the end of your command!