Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 332223 - COLOR_LIST_SELECTION and COLOR_LIST_SELECTION_TEXT are incorrect on Mac
Summary: COLOR_LIST_SELECTION and COLOR_LIST_SELECTION_TEXT are incorrect on Mac
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.1   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Scott Kovatch CLA
QA Contact: Silenio Quarti CLA
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-09 11:28 EST by Mark McLaren CLA
Modified: 2021-12-20 03:00 EST (History)
3 users (show)

See Also:


Attachments
Example list that uses the workaround I mentioned (196.20 KB, image/png)
2010-12-10 09:21 EST, Mark McLaren CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark McLaren CLA 2010-12-09 11:28:52 EST
Build Identifier: 3.7m3

On my Mac (OSX 10.6.6), when I select a row in a table the background of the selected row is dark blue and the text is white.  However, these are not the colors returned by Device.getSystemColor().

The example below shows a light-blue color when it should be dark-blue.





Reproducible: Always

Steps to Reproduce:
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class TestColor {


	public static void main(String[] args) {
		Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setSize(300, 300);
		shell.setBackground(display.getSystemColor(SWT.COLOR_LIST_SELECTION));
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}
Comment 1 Scott Kovatch CLA 2010-12-09 19:49:29 EST
StyledText is using COLOR_LIST_SELECTION as the color of the text selection background color. It's an unfortunate selection of a constant name -- COLOR_TITLE_BACKGROUND is the color you are describing in this example.

There's no way we can change COLOR_LIST_SELECTION, unfortunately. What are you trying to do with the color?
Comment 2 Mark McLaren CLA 2010-12-10 09:19:44 EST
Hi Scott - I'm listening for an EraseItem event and drawing the row text color depending on whether it is ticked.  See here for an example on Windows Vista:
http://www.solaraccounts.co.uk/images/screenshots/reconcile.jpg

My workaround is to define my own constants:
int COLOR_LIST_SELECTION = isMac ? SWT.COLOR_TITLE_BACKGROUND : SWT.COLOR_LIST_SELECTION;
int COLOR_LIST_SELECTION_TEXT = isMac ? SWT.COLOR_WHITE : SWT.COLOR_LIST_SELECTION_TEXT;

I can understand if you cannot change the constant name.  Perhaps the javadoc for SWT.COLOR_LIST_SELECTION could mention this problem?  It currently says: "System color used to paint list selection background areas"
Comment 3 Mark McLaren CLA 2010-12-10 09:21:56 EST
Created attachment 184956 [details]
Example list that uses the workaround I mentioned
Comment 4 Scott Kovatch CLA 2010-12-10 10:44:50 EST
Added Felipe and Silenio for commentary. I think updating the javadoc is a good first start; maybe in the longer term we need additional system color constants? I agree it's not clear at all that COLOR_LIST_SELECTION is the selected text background color.
Comment 5 Felipe Heidrich CLA 2010-12-10 12:38:09 EST
I'd argue that the javadoc is correct. As in COLOR_LIST_SELECTION and COLOR_LIST_SELECTION_TEXT are the backgroung/foreground colors that org.eclipse.swt.widgets.List use to draw a select item.

You can argue that the RGB values for these constants are wrong on cocoa (COLOR_LIST_SELECTION is not the background color of a selected item in the List).

But as Scott said, changing this value would break StyledText that depends on the current value. 

Silenio, do you think we need new constants (for selected text) ?
Comment 6 Silenio Quarti CLA 2010-12-21 13:09:19 EST
We would have to add four new constants:

COLOR_TEXT_FOREGROUND
COLOR_TEXT_BACKGROUND
COLOR_TEXT_SELECTION
COLOR_TEXT_SELECTION_TEXT

And change StyledText to use the new constants. We would probably break any other custom editor because COLOR_LIST_SELECTION would be different on Mac.

Note that this is realy open ended in the new world of themes.
Comment 7 Eclipse Webmaster CLA 2019-09-06 15:32:55 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
Comment 8 Eclipse Genie CLA 2021-12-20 03:00:27 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.