Re: Programmatically popup a tooltip




A. Pagaltzis said:
* ofey aikon <ofey aikon gmail com> [2005-05-13 17:40]:
If you are wondering what I am upto, I want to move my mouse
over a Gtk2::Image and based on the co-ordinates, I want to
popup a tooltip and display different text.

The only straightforward solution seems to be to put the
Gtk2::Image in a Gtk2::Fixed container and then position
Gtk2::EventBox objects on top of the image at the desired
coordinates â?? you can then associate an individual tooltip with
each eventbox. This doesnâ??t seem very satisfactory, but despite a
good amount of searching I canâ??t see how widgets and tooltips
interface with each other, so there seems not to be any easier
approach.

That sounds like a recipe for resource starvation.  Each EventBox creates its
own GdkWindow, which corresponds to an X window.  If you wanted a different
mouseover for every pixel in the image, that's a lot of very small windows.

The tooltip attaches itself to a widget's event-after signal (the signal that
fires *after* each event, in case you didn't know such a beast existed :) and
listens for enter and leave.  When it gets an enter, if no tooltip is visible,
a timeout is installed to pop one up, else the current widget's tooltip is
displayed; when it gets a leave, the tooltip is torn down.  All of that is in
gtktooltips.c:
http://cvs.gnome.org/viewcvs/gtk%2B/gtk/gtktooltips.c?rev=1.66&view=markup


The positioning of the tooltip is based on the widget's allocation.  That's
pretty much the reason that GtkTreeView doesn't have tooltips.  You know
GtkCList and GtkCTree could show a tooltip for each row when partially
obscured?  Yes, that's a feature regression, and there's been a bug about it
in bugzilla for several years.  The solution is big changes to the design of
tooltips to allow a widget to participate in the positioning and text content
of a tooltip.

... which is exactly what Ofey is looking for, as i understand it.



As a workaround, what about using a normal label somewhere in the window (e.g.
a status bar), and update that label as you move the mouse over the image? 
Like, for example, the gimp's pixel-coordinate display in the lower-left
corner of each image window.



-- 
muppet <scott at asofyet dot org>




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]