user2738698
user2738698

Reputation: 568

How to restrict SWT text field to a set amount of characters?

Is there a built-in method for stopping user input when a certain number of characters have been entered? I was looking for an alternative to VerifyListeners.

Upvotes: 2

Views: 3250

Answers (2)

tjalling
tjalling

Reputation: 503

Do you mean that you want the input to your text field to be limited to a certain number of characters (at the same time)? In that case, you can use Text.setTextLimit() (see this answer).

Upvotes: 3

Victor
Victor

Reputation: 3978

Sure there is. Check this answers or perhaps this one that is not attaching an event handler (or at least, not directly) for key pressed.

Hope it helps!

Upvotes: -1

Related Questions