Filtering/validating text input

I need to have a text editing field where I validate what the users type. I’m currently using Label and Label::setEditable() to provide the text field.

I’m thinking of using either Component::focusLost() or Label::Listener::labelTextChanged() to run some validation on the text obtained by Label::getText( true ), and then highlighting problems to the user as necessary. Before I do this, I figured I would ask in case I missed some other obvious or easier method by which the user’s input can be filtered and/or validated.

There’s a function in TextEditor that lets you limit the set of characters that it allows, but if you need more complicated semantics, then you’d probably want to add an event handler when the text changes, and forcibly use setText if it’s wrong.