Can you limit what characters can be typed into a MATLAB GUI editbox?

蹲街弑〆低调 提交于 2019-11-30 03:43:50

问题


I want to make an editbox in a MATLAB GUI which will only allow numbers or only allow letters to be typed into it. Is this possible?


回答1:


There is no such feature, at least not a documented one. You could assign a callback that will check the input, but that will happen after the user entered illegal character. Though I don't know how exactly to do it, my guess is that you can use Java GUI.
Another interesting option is to add an ActiveX that will do the job.

Edit: I have found an ActiveX that does the job. Downdload it, register by calling

Regsvr32 NumberBox.ocx

And thein add an ActiveX in Matlab Guide. The name will be NumberBox.NbrTextBox. You can do it by cliking the ActiveX button in Guide:



来源:https://stackoverflow.com/questions/8853274/can-you-limit-what-characters-can-be-typed-into-a-matlab-gui-editbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!