Disabling Characters in Edit Box

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • 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.

  • 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.

  • Ah yeah, I should probably mention that this came about because my project doesn't allow the use of third party extensions. Most methods I tried first would always set the Edit Box carat back to the start of the text which was a big annoyance. The main advantage of my method was that it didn't involve the use of extensions and worked mostly as I had hoped, but anyone not plagued by this restriction should probably look up extensions for their needs :)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!