Edit Textbox non numerical values

3 次查看(过去 30 天)
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 个评论
Adam
Adam 2016-4-26
编辑:Adam 2016-4-26
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 2016-4-26
You can use KeyPressCallback to do live correction but it is seldom worthwhile. Especially when you take scientific notation into account

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by