SWT 单选按钮回滚选择更改

发布于 2024-09-13 08:40:41 字数 232 浏览 5 评论 0原文

我对带有 SWT.RADIO 标志的按钮有一些问题;

我想要的是防止在某些情况下更改某些按钮

场景

我们有三个按钮,在选择更改时系统会验证是否允许这样做。如果不是,那么我们不想设置新的选择。

那么真正的问题是什么,我正在选择侦听器上进行操作。当我们更改选择时,侦听器会被触发两次;首先隐藏其他项目的选择,然后隐藏当前所选按钮的选择。

我有办法简单地或正常地做到这一点吗?

I have some problem with button withs flag SWT.RADIO;

What i want to is to prevent the change of some button in some circumstances

case scenario

We have three buttons, on selection change the system verifies that this is allowed. if not then we don want to set new selection.

So what the real problem, i am operating on selection listener. When we change the selection the listener is fired twice; first to hide selection of other item and then selection for current selected button.

I there a way to do this simply, or normal ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

一页 2024-09-20 08:40:41

手动撤消选择并不是一个好主意。您应该能够通过设置 event.doit = false 在选择侦听器内。您可以通过检查 ((Button) event.source).getSelection()) 的选择状态来忽略其中一个回调

Manually undoing selection is not a good idea. You should be able to disable selection by setting event.doit = false inside selection listener. You can ignore one of the callbacks by checking the selection state of ((Button) event.source).getSelection())

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