Trigger a Button_Click function when hitting enter [SOLVED]

Started by Akatosh, Mon 01/01/2007 13:48:48

Previous topic - Next topic

Akatosh

Right: I've got a textbox and an associated button next to it. Is there any other way to call the button_click function on hitting enter than trickstering around with the key_press function and if - Structures?

Ishmael

I don't think there is, but it isn't a big deal...

if (keycode == 13) { // was enter, I think. Double-check that, though.
Ã,  if (gTextbox.Visible == true) {
Ã,  Ã,  button_click();
Ã,  }
}

You just need to make sure the button_click function is before the on_key_press function for this to work.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Ashen

If there's a TextBox on the GUI, on_key_press AFAIK won't run - the TextBox claims all keypresses. Just call the Button's control function from the TextBox's, e.g.:
Code: ags

function btnText_Click(GUIControl *control, MouseButton button) {
  DoStuff();
}

function txtText_Activate(GUIControl *control) {
  btnText_Click(txtText, eMouseLeft);
}


It shouldn't matter what parameters you use when you call it, provided they're there.
I know what you're thinking ... Don't think that.

Akatosh


SMF spam blocked by CleanTalk