set limit number of possible characters in textedit
Is it possible to set a limit to the number of letters that can be entered in a textedit object? I would like to limit the max number to lets say 200 characters (spaces included) and show the number of remaining characters.
The answer to your question is of course: Yes.
But I'm sure you want more than that.
Here's a quick hack using the readonly attribute. Edit: Modified to support backspace (ASCII 8) to enable changing text while maintaining character limit.
niiiice!
Unfortunately there are further special keys to take into account (such as enter/return) that are handled as entered characters in the above.
I'd favour a method where you count what's in the box each time (as the below). It suffers from slightly odd trailing whitespace issues (due to textedit stripping them from the output), but otherwise it should work, whatever is typed in.
The other issue arising in the above patch is that once you reach the limit you can't edit it any more.
The below also doesn't have a count down (but it's trivial - take the length away from the maximum - and you'll need to store the output and check for a tab or return character to send to the final output, but again that's fairly minor to add using zl reg or something...
A.