Restricting characters in TextInput can be easily done, but how can I check if particular character was restricted without manually parsing the restrict property?
For example: restrict='a-zA-Z^L-W'.
How do i get that B is allowed and M is forbidden?
If it matters, I need this functionality to show a user the explanation why his key presses don't affect the input content.
I was able to implement the message by checking input.text.indexOf(keydownchar)==-1, but I'm interested if there's any SDK method to check the char without trying to append it into the input control.
It can be done with
It is exactly the method used by text display controls like
RichEditableTextto handlerestrictproperty.There's also more suitable method for testing single char, but unfortunately it's private:
Anyways it is used inside
StringUtil.restrict, so usingStringUtil.restrictinstead oftestCharacterwill produce the same result with performance overhead.