Pressing Return key within a Textbox

Started by shaun9991, Wed 26/06/2024 20:52:02

Previous topic - Next topic

shaun9991

Hi guys,

I've had a long time away from AGS and am super rusty - I'm using AGS 3.6.1.24 for the first time to play around with something - and I can't get the onkeypress function to work properly from within a textbox. I just want the player to be able to type their name and press the Return key, then the game moves on.

As an example, i've put this in globalscript on_key_press as I normally would (the textbox is included within gPassword)

if(gPassword.Visible == true)
  {
    if(keycode == eKeyReturn){
      //code here
      //eg
      Display("Done!");
    }


but instead of displaying "Done!", nothing happens. Am I doing something stupid? The keypresses work fine if a textbox is not displayed on the screen

Apologies, super rusty!
Shaun
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

Snarky

#1
TextBoxes eat all keypresses, so on_key_press is never called. Instead you have to use the TextBox.OnActivate event (from the event pane in the GUI editor).

Welcome back, BTW!

shaun9991

Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

SMF spam blocked by CleanTalk