class Gtk::Tooltip
- Gtk::Tooltip
- GObject::Object
- Reference
- Object
Overview
Gtk::Tooltip
is an object representing a widget tooltip.
Basic tooltips can be realized simply by using
Gtk::Widget#tooltip_text=
or
Gtk::Widget#tooltip_markup=
without
any explicit tooltip object.
When you need a tooltip with a little more fancy contents,
like adding an image, or you want the tooltip to have different
contents per Gtk::TreeView
row or cell, you will have to do a
little more work:
-
Set the [property@Gtk.Widget:has-tooltip] property to
true
. This will make GTK monitor the widget for motion and related events which are needed to determine when and where to show a tooltip. -
Connect to the [signal@Gtk.Widget::query-tooltip] signal. This signal will be emitted when a tooltip is supposed to be shown. One of the arguments passed to the signal handler is a
Gtk::Tooltip
object. This is the object that we are about to display as a tooltip, and can be manipulated in your callback using functions likeGtk::Tooltip#icon=
. There are functions for setting the tooltip’s markup, setting an image from a named icon, or even putting in a custom widget. -
Return
true
from your ::query-tooltip handler. This causes the tooltip to be show. If you returnfalse
, it will not be shown.
Defined in:
lib/gi-crystal/src/auto/gtk-4.0/tooltip.crConstructors
Class Method Summary
-
.g_type : UInt64
Returns the type id (GType) registered in GLib type system.
Instance Method Summary
-
#custom=(custom_widget : Gtk::Widget?) : Nil
Replaces the widget packed into the tooltip with @custom_widget.
-
#icon=(paintable : Gdk::Paintable?) : Nil
Sets the icon of the tooltip (which is in front of the text) to be @paintable.
-
#icon_from_gicon=(gicon : Gio::Icon?) : Nil
Sets the icon of the tooltip (which is in front of the text) to be the icon indicated by @gicon with the size indicated by @size.
-
#icon_from_icon_name=(icon_name : String?) : Nil
Sets the icon of the tooltip (which is in front of the text) to be the icon indicated by @icon_name with the size indicated by @size.
-
#markup=(markup : String?) : Nil
Sets the text of the tooltip to be @markup.
-
#text=(text : String?) : Nil
Sets the text of the tooltip to be @text.
-
#tip_area=(rect : Gdk::Rectangle) : Nil
Sets the area of the widget, where the contents of this tooltip apply, to be @rect (in widget coordinates).
Instance methods inherited from class GObject::Object
bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding
bind_property,
bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding
bind_property_full,
data(key : String) : Pointer(Void)?
data,
finalize
finalize,
freeze_notify : Nil
freeze_notify,
getv(names : Enumerable(String), values : Enumerable(_)) : Nil
getv,
notify(property_name : String) : Nil
notify,
notify_by_pspec(pspec : GObject::ParamSpec) : Nil
notify_by_pspec,
notify_signal
notify_signal,
property(property_name : String, value : _) : Nil
property,
qdata(quark : UInt32) : Pointer(Void)?
qdata,
ref_count : UInt32
ref_count,
run_dispose : Nil
run_dispose,
set_data(key : String, data : Pointer(Void)?) : Nil
set_data,
set_property(property_name : String, value : _) : Nil
set_property,
steal_data(key : String) : Pointer(Void)?
steal_data,
steal_qdata(quark : UInt32) : Pointer(Void)?
steal_qdata,
thaw_notify : Nil
thaw_notify,
to_unsafe : Pointer(Void)
to_unsafe,
watch_closure(closure : GObject::Closure) : Nil
watch_closure
Constructor methods inherited from class GObject::Object
cast(obj : GObject::Object) : self
cast,
cast?(obj : GObject::Object) : self?
cast?,
new(pointer : Pointer(Void), transfer : GICrystal::Transfer)new new, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv
Class methods inherited from class GObject::Object
compat_control(what : UInt64, data : Pointer(Void)?) : UInt64
compat_control,
g_type : UInt64
g_type,
interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec
interface_find_property,
interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec)
interface_list_properties
Constructor Detail
Class Method Detail
Instance Method Detail
Replaces the widget packed into the tooltip with
@custom_widget. @custom_widget does not get destroyed when the tooltip goes
away.
By default a box with a Gtk::Image
and Gtk::Label
is embedded in
the tooltip, which can be configured using gtk_tooltip_set_markup()
and gtk_tooltip_set_icon().
Sets the icon of the tooltip (which is in front of the text) to be
@paintable. If @paintable is nil
, the image will be hidden.
Sets the icon of the tooltip (which is in front of the text)
to be the icon indicated by @gicon with the size indicated
by @size. If @gicon is nil
, the image will be hidden.
Sets the icon of the tooltip (which is in front of the text) to be
the icon indicated by @icon_name with the size indicated
by @size. If @icon_name is nil
, the image will be hidden.
Sets the text of the tooltip to be @markup.
The string must be marked up with Pango markup.
If @markup is nil
, the label will be hidden.
Sets the text of the tooltip to be @text.
If @text is nil
, the label will be hidden.
See also Gtk::Tooltip#markup=
.
Sets the area of the widget, where the contents of this tooltip apply,
to be @rect (in widget coordinates). This is especially useful for
properly setting tooltips on Gtk::TreeView
rows and cells, Gtk::IconViews
,
etc.
For setting tooltips on Gtk::TreeView
, please refer to the convenience
functions for this: gtk_tree_view_set_tooltip_row() and
gtk_tree_view_set_tooltip_cell().