Legacy GM [SOLVED] keyboard_string conflict

A

Alan Régis

Guest
So, i have 2 objects using the keyboard_string variable to generate user text input, something like this:

Code:
// obj_chat_box
if chatbox_selected
     {
     text = keyboard_string;
     }
else
     {
      keyboard_string = text;
     }
Code:
// obj_character_sheet
if input_text_selected
     {
     char_text = keyboard_string;
     }
else
     {
      keyboard_string = char_text;
     }
I have tried some some "if" statements regarding if the input boxes are selected and theres always something wrong, like:
  • keyboard_string variable placing text in both fields at the same time.
  • Recording characters while the input boxes are not selected and printing then instantly when i select one.
  • Not able to draw the string at all.

I know there are other ways to make text input boxes, using keyboard_lastchar, but is not as practical, so... is there a way to fix this?
 
I

icuurd12b42

Guest
set a global somewhere
global.selected = noone;

in your editable mouse pressed (you must have a mask or a sprite on the object
global.selected = id;
keyboard_string = MyText;

in the draw
if(global.selected == id)
{
MyText = keyboard_string;
}
draw_text(x,y,MyText);
 
A

Alan Régis

Guest
set a global somewhere
global.selected = noone;

in your editable mouse pressed (you must have a mask or a sprite on the object
global.selected = id;
keyboard_string = MyText;

in the draw
if(global.selected == id)
{
MyText = keyboard_string;
}
draw_text(x,y,MyText);
Perfect! Exactly the solution i needed. Thank you very much!
 
Top