Community
Participate
Working Groups
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(""); } });
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 ***