您能否限制可以在 MATLAB GUI 编辑框中输入哪些字符?

发布于 2024-12-27 00:52:23 字数 50 浏览 1 评论 0原文

我想在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

韶华倾负 2025-01-03 00:52:23

不存在这样的功能,至少没有记录在案。
您可以指定一个回调来检查输入,但这将在用户输入非法字符之后发生。虽然我不知道具体该怎么做,但我猜你可以使用 Java GUI。
另一个有趣的选择是添加一个可以完成这项工作的 ActiveX。

编辑:
我找到了一个 ActiveX 可以完成这项工作。下载它,通过调用注册

Regsvr32 NumberBox.ocx

并在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

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:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文