X
XirmiX
Guest
Two problems; if I have this code, I will be able to:
* Type by pressing keys
* Delete by pressing backspace
* Delete by holding down backspace
But if I add in a block of code, so that this is the code that I have, then I will be able to:
* Type by pressing keys
* Type by holding down keys
* Delete by pressing backspace
But I will no longer be able to delete by holding down backspace... why? And how do I fix this?
And secondly, this is my selection code (for when the Left mouse button clicks on the text box):
if I have not selected the textbox via mouse first, I will not have the keys drawn, which is what I want, but when I click the box, the keys I previously pressed will be in there. Why? And how do I fix this?
And just in case, here's my creation code:
And this is my draw code:
* Type by pressing keys
* Delete by pressing backspace
* Delete by holding down backspace
Code:
///Typing code
//Checks whether this text box is selected
if self.selected == true
{
//Keys held down
if keyboard_check(keys_allowed) && (string_length(text_written) < 30) && type_timer == 2
{
text_written = text_written+(keyboard_string);
type_timer = 0;
keyboard_string = "";
}
//Backspace held down
if keyboard_check(vk_backspace) && !keyboard_check_pressed(vk_backspace) && type_timer == 2
{
text_written = string_delete(text_written, string_length(text_written), 1);
type_timer = 0;
keyboard_string = "";
}
//Backspace pressed
if keyboard_check_pressed(vk_backspace)
{
text_written = string_delete(text_written, string_length(text_written), 1)
type_timer = -8;
keyboard_string = "";
}
//Resetting the timer for typing
if type_timer != 2
{
type_timer++;
}
}
* Type by pressing keys
* Type by holding down keys
* Delete by pressing backspace
Code:
///Typing code
//Checks whether this text box is selected
if self.selected == true
{
//Keys held down
if keyboard_check(keys_allowed) && (string_length(text_written) < 30) && type_timer == 2
{
text_written = text_written+(keyboard_string);
type_timer = 0;
keyboard_string = "";
}
//Backspace held down
if keyboard_check(vk_backspace) && !keyboard_check_pressed(vk_backspace) && type_timer == 2
{
text_written = string_delete(text_written, string_length(text_written), 1);
type_timer = 0;
keyboard_string = "";
}
//Keys pressed
if keyboard_check_pressed(keys_allowed) && (string_length(text_written) < 30)
{
text_written = text_written+(keyboard_string);
type_timer = -8;
keyboard_string = "";
}
//Backspace pressed
if keyboard_check_pressed(vk_backspace)
{
text_written = string_delete(text_written, string_length(text_written), 1)
type_timer = -8;
keyboard_string = "";
}
//Resetting the timer for typing
if type_timer != 2
{
type_timer++;
}
}
And secondly, this is my selection code (for when the Left mouse button clicks on the text box):
Code:
///If the text box is clicked on
//Text box is selected
{
selected = true;
}
And just in case, here's my creation code:
Code:
///Initial textbox code
{
keys_allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-";
type_timer = 2;
text_written = "";
textbar_selected = false;
max_symbols_allowed = 30;
selected = false;
display_x = x+6;
display_y = y+16;
}
Code:
///Text box and text is drawn
{
draw_self();
draw_set_color(c_lime);
draw_text(display_x, display_y, text_written);
}