Clear Filters
Clear Filters

Edit Textbox non numerical values

3 views (last 30 days)
H.Hogarth
H.Hogarth on 26 Apr 2016
Commented: Walter Roberson on 26 Apr 2016
Hi, i have 5 edit text boxes where by the user can enter data into each of them and a graph is plotted depending on the data supplied. I have it working so numerical values work and when non-numerical data in supplied nothing occurs. Im wondering is there a way for matlab to detect that letters have been inputed and in-turn produce a warning popup? Many Thanks
  2 Comments
Adam
Adam on 26 Apr 2016
Edited: Adam on 26 Apr 2016
I assume from what you say then that you already have the test for whether the string is numeric or not.
Edit boxes only trigger their callback when you click 'Enter' or move focus away from the edit box. Trying to do validation live is a tricky business that is rarely worthwhile. I think in this case you would need to get hold of the underlying Java object and use its callbacks rather than the matlab callback.
I have often thought of creating my own numeric editbox class before, but this is what always puts me off doing so.
You can add a Timer object and start doing checks at some interval or other if you really want, but it can get messy.
If you are using R2016a the new appdesigner actually includes a NumericEditField text box for this purpose, but I haven't used it. As far as I am aware these components cannot be used outside of appdesigner GUIs.
Walter Roberson
Walter Roberson on 26 Apr 2016
You can use KeyPressCallback to do live correction but it is seldom worthwhile. Especially when you take scientific notation into account

Sign in to comment.

Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!