Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 90125 - Tooltip behavior in Composite erratic
Summary: Tooltip behavior in Composite erratic
Status: RESOLVED DUPLICATE of bug 85328
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-03 20:05 EDT by trevor campbell CLA
Modified: 2005-04-03 20:53 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description trevor campbell CLA 2005-04-03 20:05:00 EDT
I have an aplication that shows a map and pops up a tooltip when the cursor
passes over a place on the map and shows the location description.

In MS Windows this behaves as expected, but in Linux GTK2 a number of things go
funny.  These may be GTK problems rather than SWT problems, I don't know.
1/ The tooltip shows below the control (not below the mouse pointer) If the
control (a canvas) is in a ScrolledComposite then the tooltip is at the bottom
of the canvas, which can be almost anywhere depending on the scrolled position.
2/  Setting the tooltip to null  ( _composite.setToolTipText(""); ) or an empty
string stops the tooltip from working until the mouse leaves and reenters the
control.  
Normally if the mouse hovers over the map ( canvas ) I set the tooltip to the
name of the place on the map and if the mouse hovers over an empty region I set
the tooltip to null.  This works in windows but not at all well in Linux-GTK.

Sample code follows

_canvas = new Canvas(_composite, SWT.NONE);
_composite.setContent(_canvas);
(other initialisation stuff ) 
_canvas.addMouseTrackListener(new MouseTrackAdapter() {
            public void mouseHover(MouseEvent e) {
                for (Point p : _wayPoints.keySet()) {
                    if (Math.abs(p.x - e.x) < 5 && Math.abs(p.y - e.y) < 5) {
                        Waypoint wp = _wayPoints.get(p);
                        _composite.setToolTipText(wp.getName());
			return;
                    }
                }
                _composite.setToolTipText("");
            }
        });
Comment 1 Billy Biggs CLA 2005-04-03 20:53:51 EDT
This happens because of the way the GTK+ tooltip system works.  There has been
some talk recently about redesigning the system upstream, see this thread on
gtk-devel-list:

  http://mail.gnome.org/archives/gtk-devel-list/2004-October/msg00120.html

There are already two bugs open about these issues, so I'll mark this one as a
duplicate of the first about the tooltips appearing outside of the window. 
Maybe we should try harder to force GTK+ into being sensible. :)

See bug 73390 about the issue of setting the text to null.  We should probably
poke on the GTK+ bug again...

*** This bug has been marked as a duplicate of 85328 ***