Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 11178

Summary: Pressed & disabled toolbar button looks enabled
Product: [Eclipse Project] Platform Reporter: Tetsuro Asahata <asahata>
Component: SWTAssignee: Grant Gayed <grant_gayed>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: bso, jeff_brown, kitlo, lmcwil, n.a.edgar
Version: 2.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows All   
Whiteboard:

Description Tetsuro Asahata CLA 2002-03-12 10:06:05 EST
Pressed & disabled toolbar button looks enabled.

How to:

1. Open a Java Editor.
2. Make sure "Text Hover" button is in pressed state.
3. Switch focus to another view such as package view.

Then the "Text Hover" button becomes pressed & disabled state,
but it looks like enabled since it's not grayed but still has colors.
Comment 1 Kevin Haaland CLA 2002-05-01 17:59:32 EDT
Tod pls try this case in the latest 2.0 builds. 
Comment 2 Tod Creasey CLA 2002-05-02 09:28:24 EDT
Still an issue in 20020501. The next and previous problem buttons gray out but 
not the Text Hover.
Comment 3 Nick Edgar CLA 2002-05-02 10:16:51 EDT
This is a known problem in SWT or Windows.
Couldn't find corresponding SWT PR.
Comment 4 Mike Wilson CLA 2002-05-02 11:03:58 EDT
This is platform behavior. Many applications (example, Word) have worked 
around this by implementing their own toolbar widgets, but the native widget 
does not support it.
Comment 5 Steve Northover CLA 2002-05-15 23:38:42 EDT
*** Bug 4619 has been marked as a duplicate of this bug. ***
Comment 6 Steve Northover CLA 2002-08-15 18:10:16 EDT
*** Bug 4850 has been marked as a duplicate of this bug. ***
Comment 7 Simon Arsenault CLA 2002-11-15 12:39:38 EST
*** Bug 8303 has been marked as a duplicate of this bug. ***
Comment 8 Sudarsha Wijenayake CLA 2004-02-20 09:12:39 EST
Also occurs in Eclipse 3.0M7 (Build ID: 200402122000) on HP-UX 11.11 and 
Solaris 9 platforms.
Comment 9 Steve Northover CLA 2004-02-20 10:39:08 EST
Not sure how it could do this because this is a Windows only limitation.  Is 
the problem you are seeing something to do with the Eclipse icons?  I think 
Eclipse had a work around for this.  Did the work around go away?
Comment 10 Brian So CLA 2004-04-07 07:30:20 EDT
Occurs in Eclipse 3.0M8 (Build ID: 200403261517) on HP-UX 11.11 and 
Solaris 9 platforms with [SWT Examples] SWT Controls->Toolbar.
Comment 11 Robert He CLA 2004-05-31 23:29:44 EDT
Occurs in Eclipse 3.0M9 (Build ID: 200405211200) on AIX 5.30 with [SWT Examples]
SWT Controls->Toolbar
Comment 12 Steve Northover CLA 2004-06-01 09:26:37 EDT
Interesting that they claim this happens on AIX.  Is it a color depth issue 
with the code that grays tool bar items?
Comment 13 Steve Northover CLA 2005-04-05 13:51:06 EDT
Fixed > 20050405 (on Windows)

Please open a new bug report for AIX and/or HP-UX if this is not fixed for you.
Comment 14 Grant Gayed CLA 2005-04-08 13:37:39 EDT
As a side note, I've verified that this works in a stand-alone snipet on linux-
motif and solaris-motif (snippet is below).

However, note that the originally-described behaviour still occurs when using 
eclipse because the CHECK ToolItem is having its selection changed by jface 
whenever it changes enablement (by ActionContributionItem.update(String)).  So 
this is happening as a result of a ui-level design, not an swt bug.

public static void main(String[] args) {
	Display display = new Display();
	Image image = new Image(display, "/opt/smiley.ico");
	Shell shell = new Shell(display);
	shell.setBounds(10,10,200,200);
	ToolBar bar = new ToolBar(shell, SWT.FLAT | SWT.BORDER);
	bar.setBounds(10,10,150,50);
	final ToolItem item = new ToolItem(bar, SWT.CHECK);
	item.setImage(image);
	item.setSelection(true);
	item.setEnabled(false);
	final ToolItem item2 = new ToolItem(bar, SWT.CHECK);
	item2.setImage(image);
	item2.setEnabled(false);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) display.sleep();
	}
	image.dispose();
	display.dispose();
}
Comment 15 Nick Edgar CLA 2005-04-08 15:35:11 EDT
I've filed bug 90852 to check out the logic in ActionContributionItem.
Comment 16 Nick Edgar CLA 2005-05-06 10:12:10 EDT
From comment 14:
> the originally-described behaviour still occurs when using eclipse because 
> the CHECK ToolItem is having its selection changed by jface whenever it
> changes enablement (by ActionContributionItem.update(String))

Please see comments in bug 90852.  ActionContributionItem.update only changes
the item's selection and enablement state when necessary.

Even if it did change it unnecessarily, I would not expect changing the
selection to have any impact on how the icon appears.  There should be no
ordering constraint here.  The icon should be grayed out if the item is
disabled, even if the selection state changes while disabled.
It appears to work this way now on Win2K in N20050505.
Comment 17 Grant Gayed CLA 2005-05-06 11:22:19 EDT
Revisiting the case, I misspoke about the behaviour I saw.  It's not that the 
item's image keeps its colour when it's disabled (which was what was described 
in comment 0), but that disabling it in eclipse makes it lose its selected 
status.  This is the selection change I was referring to that originates in 
ActionContributionItem.  However I believe that this is being done by design 
for aestetic purposes, so there's no action required here.  Sorry for the 
misleading comment in comment 14.
Comment 18 Nick Edgar CLA 2005-05-06 12:11:14 EDT
Just to be clear, which action did you see having its selected state changed
when disabled?  If it's a retargetable action, the item will be unselected if
the new part has no handling action.  This is done to reflect the actual state
from the part, not for aesthetics.

Comment 19 Grant Gayed CLA 2005-05-06 12:19:40 EDT
Toggle Mark Occurrences and Show Source Of Selected Element Only
Comment 20 Nick Edgar CLA 2005-05-06 15:18:56 EDT
These are both retargetable, so having the selection change is expected.