Help with my text box system [FIXED]

Geners

Member
SO

I created this really basic text input system, the only problem is, when I have multiples the text copies over whenever I click on a different box. I know exactly what's causing this problem, but I'm having somewhat of a difficult time coming up with a work around. Any help would be fantastic.

Here's my create event for my text box
Code:
focused = false;
input = "";
cursor = "|";
cursorDelay = 15;
alarm[0] = cursorDelay;
step event
Code:
/*checks to see if this field is being clicked on*/ 
if(mouse_check_button_pressed(mb_left)) {
    if(position_meeting(mouse_x,mouse_y,self)) {
        focused = true; 
    }
    else { 
        focused = false; 
    }
}

/*if clicked on, allow to input and limit how much can be typed*/
bufferSpace = 10;
if(focused && (string_width(keyboard_string) < sprite_width - bufferSpace)) {
        input = keyboard_string;
}
draw event
Code:
/*Draw the text being inputed*/
draw_self(); 
draw_set_valign(fa_middle);
draw_set_color(c_black);
draw_set_font(FinputFont); 

if(focused) {
    draw_text(x,y,input + cursor);
}
else {
    draw_text(x,y,input);
}
Now when I have only one text box in existence in the room it's fine. But once I have multiple, I click and type in one of the boxes, and then switch focus it displays what I typed previously in the new one.

Now, I'm pretty sure the nature of
Code:
keyboard_string
is what's causing this. Every step it's plugging in the keyboard string but the keyboard string doesn't change or alter when changing between boxes. I could store what was typed in the box in another variable once something else is clicked, but once that box is clicked again it will go back to keyboard string. Any easy work around for this? I would super appreciate it.
 
Top