您能否限制可以在 MATLAB GUI 编辑框中输入哪些字符?
我想在 MATLAB GUI 中创建一个编辑框,仅允许在其中输入数字或字母。这可能吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不存在这样的功能,至少没有记录在案。
您可以指定一个回调来检查输入,但这将在用户输入非法字符之后发生。虽然我不知道具体该怎么做,但我猜你可以使用 Java GUI。
另一个有趣的选择是添加一个可以完成这项工作的 ActiveX。
编辑:
我找到了一个 ActiveX 可以完成这项工作。下载它,通过调用注册
并在Matlab Guide中添加一个ActiveX。名称将为NumberBox.NbrTextBox。
您可以通过单击指南中的 ActiveX 按钮来完成此操作:
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
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: