Xfce Foundation Classes
 « Main Page | Index

The Tooltips Object

Tooltips are the little text strings that pop up when you leave your pointer over a button or other widget for a few seconds. They are easy to use, so I will just explain them without giving an example. Widgets that do not receive events (widgets that do not have their own window) will not work with tooltips.

You only need to construct one Tooltip object for a set of tooltips because it can be used to create multiple tooltips:


Once you have created a new tooltip, and the widget you wish to use it on, simply use this call to set it:

void set_tip(Gtk::Widget& widget, const String& tip_text, const String& tip_private = 0);

The 'widget' argument is the widget you wish to have this tooltip pop up for. The 'tip_text' argument is the text you want the tooltip to display. The 'tip_private' argument is a text string that can be used  to implement context sensitive help. For now, it is not enabled in GTK so you can just ignore it.  

Here's a short example:

Gtk::Button *button = new Gtk::Button("button 1");
Gtk::Tooltips tooltips;
tooltips.set_tip(button, "This is button 1");

There are other calls that can be used with tooltips. I will just list them with a brief description of what they do.

void enable();

Enable a disabled set of tooltips.

void disable(); 

Disable an enabled set of tooltips.

bool is_enabled()

Returns true if a set of tooltips is enabled.

void unset_tip(Gtk::Widget& widget);

Unset a previously set tooltip. And that's all the functions associated with tooltips. More than you'll ever want to know.

Copyright © 2004-2005 The XFC Development Team Top
XFC 4.4