textfield mask and limit text question

I have a textfiled, if I set up the limit text ONLY, let’s say 10, when I input the text it will behave as I expected. I mean after input 10 characters, I couldn’t input anymore, unless I delete 1 character from the textfield.

But when I add mask to this textfield, like only allow uppercases letters. So textfield.mask = “>” and textfield.limittext = 10 at the same time. After I input 10 characters, it will stop me to input a charater at the end of string, but if I move the cursor to front position, I can still input characters and those characters will kick the last characters out of the max input limit bound. For example, “ABCDEFGHIJ”, you cannot input any characters after “J”, but you can insert "Z"before “J” at any position. So if I input “Z” before “A”, the string will become “ZABCDEFGHI”.

So my question is how can I make it behave like first senario, which you cannot input any character unless you delete one?

Masks never worked properly for me.

You could try Norman’s Masked Edit Field . I’ve used it when I find, like you, textfield’s masking is lacking or broken.

You can monitor the length of the Text property in Keydown and if the maximum is reached return true.

That will fix what you describe with inserting before existing text.

[quote=214185:@Michel Bujardet]You can monitor the length of the Text property in Keydown and if the maximum is reached return true.

That will fix what you describe with inserting before existing text.[/quote]
Then how can I delete a character? The “backspace” is not working either.

How to import that?

Look at the value of key, and if chr(8) do not return true.

Open the MaskedField.rbp file with your version of Xojo, then drag the MaskedField class to your own project. It should now show up in your Controls Library.

This will do what you asked, and let you use backspace, delete and arrow keys, etc.

Function KeyDown(Key As String) As Boolean if len(me.text) = me.LimitText and asc(key) >= 32 then return true end if End Function

Thanks,

[quote=214365:@Michel Bujardet]This will do what you asked, and let you use backspace, delete and arrow keys, etc.

Function KeyDown(Key As String) As Boolean if len(me.text) = me.LimitText and asc(key) >= 32 then return true end if End Function [/quote]

Thank you, too.