• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

text field see if is clicked in

Darnok

Member
i have a text field were want to enter a name but i want so you can only write in it if you click in it and if you click out of it you cant write again any ideas ? thx
 

Gamebot

Member
CREATE:
Code:
focus = false;
STEP:
Code:
// ASSUMING YOUR USING A SPRITE FOR THE TEXT BOX //

if (mouse_check_button_pressed( mb_left ) ) {
   with ( all ) { focus = false; }

  if ( position_meeting( mouse_x, mouse_y, self) {
  with ( id )  { focus = true;  }
  }
}

if ( focus ) {
  // YOUR TYPING CODE HERE //
}
EDIT: Small clerical error also If you need multiple boxes for different kinds of input I would go with an array. You can draw your "text box" over the sprites then hold and check in a script somewhere if its the proper input.
 
Last edited:
Top