TextEditor OR Label ? Which to use

I have a series of texteditors where user can enter ONLY numeric values. And, based on certain conditions, these text editors get enabled or disabled.

However, when I disable a TextEditor, I do not get the same visual effect that we have when we disable a label !!!

  1. If I use labels as UI for user to input values, I cannot validate if user has entered only numeric values, but when I disable the label, the text gets grayed out, and it appears disabled even visually to the user.

  2. If I use TextEditor, I can easily restrict user from entering only numeric values by using setInputRestrictions(), but when I disable the texteditor, visually it does not appear to be disabled as the text within doest not get grayed out…

Can anybody help ?


You can make a custom Label that uses any kind of texteditor you like - just overload Label::createEditorComponent(), call the parent class’s version of that method to create the editor, then tweak any flags on it that you need to before returning it.