Disabling Characters in Edit Box
I've just been trying to solve the problem of stopping users from entering certain characters into an Edit Box and I've found quite a simple method of doing so which I didn't see when searching the forums and googling.
This method does render the Undo function a bit useless but I don't think that's too big an issue for most people. Also, apologies if people have their own methods or better methods, I just thought I'd share for people with a similar problem in future who are also searching the forums.
Basically, this method just consists of clearing the Undo buffer every time the Edit Box entry zone has been modified, and if the Edit Box entry zone has been modified and an unwanted character has been found in the entry zone then Undo; so only the last character input is disabled. This disables copy/pasting as well as any single character input, at any point within the string.
Events are as follows:
Code:
+Edit Box has just been modified
+Find ( Edittext$( "Edit Box" ), "*", 0 )
- Undo
+Edit Box has just been modified
- Clear undo buffer
Simply replace the * to disable the characters of your choosing.
EDIT: I assumed adding more Find events would enable you to disable more characters but upon further use I've noticed you'll have to duplicate the entire first event to disable extra characters. This may get messy if you're trying to disable many characters (all symbols, for example) but works great if you're just trying to disable spaces like I was.
Disabling Characters in Edit Box
A method that works for my needs was to have two edit boxes. A primary and a mirror. Whenever the primary edit was modified, that character was compared to a string of allowable characters. If it was found to be allowable, that character was added to the mirror edit box, then cleared from the primary edit. If the character was not found to be allowable, it was cleared from the primary edit and not added to the mirror. It worked well and the user didn't really know this was happening behind the scenes once Looki's edit cursor extension was also implemented.