Catch Return key while in text box

Started by fratello Manu, Sat 26/12/2020 16:24:31

Previous topic - Next topic

fratello Manu

Hi everyone!
I have a GUI with a textbox. I'd like the user to write something, and then to get a confirmation pressing Return (e.g. make something happen)
How could I do it?

I put in global script:

Code: ags
// called when a key is pressed
function on_key_press(eKeyCode keycode)
{
if (keycode == eKeyReturn) 
  {
    // Text box input accept:
    if (gGuiText.Visible == true)
    {
      // Hide GUI 
      gGuiText.Visible = false;
      
      //..........DoSomethingElse();
    }
  }
}


I think the text box which is in GUI has the focus, so it prevents the Return key to be processed by the on_key_press function.

Any idea?

Thanks!
manu

Crimson Wizard

TextBox has OnActivate event which is called when player presses return.


SMF spam blocked by CleanTalk