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

Bug 317843

Summary: SWT.COLOR_INFO_BACKGROUND is brighter than the OS tooltip bg color
Product: [Eclipse Project] Platform Reporter: Markus Keller <markus.kell.r>
Component: SWTAssignee: Scott Kovatch <skovatch>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, eclipse.felipe, Silenio_Quarti, skovatch
Version: 3.7   
Target Milestone: 3.7 M1   
Hardware: PC   
OS: Mac OS X   
Whiteboard:
Bug Depends on:    
Bug Blocks: 313530    

Description Markus Keller CLA 2010-06-24 11:20:36 EDT
N20100623-2000 Cocoa, Mac OS X 10.6.4

SWT.COLOR_INFO_BACKGROUND is brighter than the OS tooltip bg color. It should not be hardcoded in Display#getWidgetColorRGB(int).

Unfortunately, Safari uses yet another color for "background-color: InfoBackground;" than native tooltips. Firefox uses the OS tooltip color.

For my application (bug 313530), it would be best if SWT could use the Safari color (251, 252, 197), not the native Tooltip color (255, 255, 199). But I could also work with the latter.


package org.eclipse.swt.snippets;

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class TooltipColorSnippet {
    public static void main(String[] args) {
        Display display= new Display();
        Shell shell= new Shell(display);
        GridLayout layout= new GridLayout();
        layout.verticalSpacing= 0;
        shell.setLayout(layout);

        Browser browser= new Browser(shell, SWT.NONE);
        browser.setText("<html><body style='" +
                "color:InfoText; background-color:InfoBackground;" +
                "font-family: \"Lucida Grande\",sans-serif; font-size: 11px;" +
                "'>" +
                "I want to look like a hover" +
        "</body></html>");
        browser.setToolTipText("I am a hover");
        browser.setLayoutData(new GridData(160, 100));

        Composite c= new Composite(shell, SWT.NONE);
        c.setToolTipText("I am a hover");
        c.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
        c.setLayoutData(new GridData(160, 100));

        shell.pack();
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.dispose();
    }
}
Comment 1 Felipe Heidrich CLA 2010-06-29 12:52:52 EDT
Is this bug on Windows XP or Mac ?
Comment 2 Markus Keller CLA 2010-06-29 14:09:34 EDT
> Is this bug on Windows XP or Mac ?
Oops, sorry. Fixed Platform field to "Mac OS X - Cocoa".
Comment 3 Scott Kovatch CLA 2010-07-14 17:44:22 EDT
I agree that it shouldn't be a hard-coded value, but there's no method in Cocoa to retrieve the tooltip color.

The native tooltip color actually should have some alpha in it. You can see this more clearly in Safari if you go to xkcd.com. He uses hovers on the comic, and if you move the mouse over the right edge of the comic so that the tooltip hangs over the edge of the image you can see it pretty clearly.

I used xScope to grab the background color of the InfoBackground and will use that as the new value. You'll need a pixel identifier or really good vision to see the difference between that and a default Cocoa tooltip.
Comment 4 Scott Kovatch CLA 2010-07-14 17:48:40 EDT
Fixed > 20100714.
Comment 5 Scott Kovatch CLA 2010-07-14 17:49:23 EDT
.