Number Editor (Text Editor)

Hi all,

I’m wondering how you all deal with letting users enter a numerical value into a TextEditor.
In this thread from 2016 there is a short discussion about the need of a NumberEditor which is silenced rather quickly.

The proposed use of setInputRestrictions() only prevents the user from entering random characters.

t->setInputRestrictions(5, “0123456789.”);
Still allows for an input like: “1.23.1”

including negative values:
t->setInputRestrictions(5, “0123456789.-”);
Still allows for an input like: “1.-23.1-”

To me it seems like a pain having to check each entry if it is a valid number. If it turns out it isn’t valid, I’d like to have the original value still in place, but there’s no way of knowing the original value, since I can only do the check in textEditorReturnKeyPressed(TextEditor &t). But at that time t.getText() already returns the gibberish that the user may have entered.

And then there’s those German speaking people who like to use , instead of .

Am I missing something?

Figured it out myself.
I think the best way is to assign a lambda function to a callback in the label .onEditorShown