Quote from: KingMick on Fri 21/04/2006 11:14:41It would be easier for a newbie like me than the on_key_press parsing idea.
the on_key_press parsing idea is excellent, and it's very easy to achieve. Probably you will find it among the simplest things in your whole script. Here's the on_key_press code for the search textboxes in my own html-like system. This is old and messy code based on strings rather than Strings, but I don't have time to update it right now:
if ((keycode >= 1) && (keycode <= 127) && (keycode != 8) && (keycode != 13) && (keycode != 9) && (keycode != 27) && (IsKeyPressed(405) == false) && (IsKeyPressed(406) == false)) {
string searchchar;
StrSetCharAt(searchchar, 0, keycode);
if ((IsKeyPressed(403) == false) && (IsKeyPressed(404) == false)) StrToLowerCase(searchchar);
string lengthtest;
StrCopy(lengthtest, searchline);
StrCat(lengthtest, searchchar);
if (GetTextWidth(lengthtest, 7) < (Game.SpriteWidth[442] - 3)) StrCat(searchline, searchchar);
}
else if ((keycode == 8) && (StrLen(searchline) > 0)) { //BACKSPACE
StrSetCharAt(searchline, (StrLen(searchline)-1), 0);
}All the conditionals in the beginning are there to make sure that the char is a proper character and that CTRL isn't held down. The reason the character is parsed as a string is to make is upper or lower case depending whether shift is held. The SpriteWidth check is only used because the textbox background is a sprite.
If you used this method, but with Strings instead of strings, you could allow the label to do it's own linebreaking, so no worries about that. As for faster typing - it seems strange that this should be slow, since I assume the game is paused while the player types. You could try to SetGameSpeed(int speed) to more than the default 40 fps. But of course this will have no effect if the slowdown is caused by your CPU.

