禁用和灰显 SWT 复合材料 [英] Disable AND grey out an SWT composite

查看:28
本文介绍了禁用和灰显 SWT 复合材料的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Composite,我希望能够以编程方式启用/禁用.Control.setEnabled(boolean enabled) 方法工作正常,但它没有提供任何小部件被禁用的视觉信息.

I have a Composite that I want to be able to enable/disable programatically. The Control.setEnabled(boolean enabled) method works fine, but it does not give any visual information that the widget(s) are disabled.

我想做的是让禁用状态意味着小部件变灰.现在他们只是进入一个奇怪的状态,用户无法点击或对他们执行任何操作.

What I would like to do is to have the disabled state mean the widgets are greyed out. Right now they just enter a weird state where the user is unable to click or perform any action on them.

推荐答案

Composite 是一个容器控件,它使用布局来容纳其他控件 - 您实际上无法看到复合,只能看到它所包含的控件.要禁用并在视觉上看到然后禁用,您必须对所有子项调用 setEnabled(false),假设它们也不是容器.基本上,必须启用/禁用叶小部件,您将看到视觉指示.

A Composite is a container control that hold other controls using a layout - you can't see a composite really, you can only see the controls it holds. To disable and visually see then disabled, you'll have to call setEnabled(false) on all the children, assuming they're not containers too. Basically, to have to enable/disable the leaf widgets and you will see visual indication.

在禁用 Composite 时您无法对小部件执行任何操作的原因是因为 Composite 正在吞噬所有事件.尽管子小部件没有转发事件,但它们对父小部件的状态一无所知,因此它们不会变灰.

The reason you can't do anything with the widgets when disabling the Composite is because the Composite is eating all the events. Although the child widgets are not getting the events forwarded, they know nothing about the state of their parent, so they aren't greyed out.

这篇关于禁用和灰显 SWT 复合材料的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆