开发者

Why is a disabled SWT link not grayed out?

开发者_开发问答I disable org.eclipse.ui.forms.widgets.Hyperlink control just calling hyperLink.setEnabled(false).

However after that the link doesn't looks like disabled control. The link is not grayed out (but I can't click it of course).

The question is: why the link is not grayed out and what should I do to gray out disabled links?


Just extend Hyperlink and set the default colors. Alternatively you could create a composite delegate and forward the interface if it isn't too big - that's probably preferable.


Note that, in addition to Santosh's answer, with Eclipse 4.3 M6, you can restore the default color more easily, since you now have:

A new constant (SWT_COLOR_LINK_FOREGROUND) has been added that will return the native color of hyperlinks on all platforms.

Why is a disabled SWT link not grayed out?


did you try setting gray foreground explicitly ?

you can use following helper method:

public static void setEnabled(Link link, boolean enable){
    if(link.isEnabled()!=enable){
        if(enable)
          link.setForeground(null); // resets to system's default color
        else
          link.setForeground(link.getDisplay().getSystemColor(SWT.COLOR_GRAY));
        link.setEnabled(enable);
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜