TextField Mask with Special Characters

  1. last year

    Steve K

    14 Mar 2017 Pre-Release Testers, Xojo Pro

    I want to apply a mask to a TextField that only allows these characters:
    <>,.-+;:_'*!#%&/()=?\[]{}$£@^|~"

    Not sure if Xojo allows for this as I don't see characters noted here or how to escape them into the mask:
    http://docs.xojo.com/index.php/TextEdit.Mask

    Do I need to write a function that checks for these? Or is there a built in method.

    create a routine in the KEYDOWN event
    something along the lines of

    return Instr("<>,.-+;:_'*!#%&/()=?\[]{}$£@^|~"+chrb(8)+chrb(3)+chrb(13),key)>0

    this should allow the characters you mentioned, plus [RETURN], [ENTER] and [BACKSPACE]

    Code supplied is for illustration purposes only. Please understand the function before pasting into your own program

  2. Dave S

    14 Mar 2017 Answer San Diego, California USA

    create a routine in the KEYDOWN event
    something along the lines of

    return Instr("<>,.-+;:_'*!#%&/()=?\[]{}$£@^|~"+chrb(8)+chrb(3)+chrb(13),key)>0

    this should allow the characters you mentioned, plus [RETURN], [ENTER] and [BACKSPACE]

    Code supplied is for illustration purposes only. Please understand the function before pasting into your own program

  3. Steve K

    19 Mar 2017 Pre-Release Testers, Xojo Pro

    Thanks @Dave S !

  4. Steve K

    22 Mar 2017 Pre-Release Testers, Xojo Pro

    Turned out I needed this:
    return NOT (Instr("<>,.-+;:_'*!#%&/()=?\[]{}$£@^|~"+chrb(8)+chrb(3)+chrb(13),key)>0)

    Thanks for the help!

  5. 3 months ago

    Thats great, but what about this Character "`" Accents? what is the hex code of that, I mean in Keyboard Xojo docs are not available

  6. Dave S

    Feb 25 San Diego, California USA

    "`"=0x60 or chrb(96)

or Sign Up to reply!