Gnome::Gtk4::Tooltip
Description
Gnome::Gtk4::Tooltip is an object representing a widget tooltip.
Basic tooltips can be realized simply by using .set-tooltip-text() in class Gnome::Gtk4::Widget
or .set-tooltip-markup() in class Gnome::Gtk4::Widget
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 Gnome::Gtk4::TreeView row or cell, you will have to do a little more work:
Set the has-tooltip defined in Gnome::Gtk4::Widget 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 query-tooltip defined in Widget 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 Gnome::Gtk4::Tooltip object. This is the object that we are about to display as a tooltip, and can be manipulated in your callback using functions like
.set-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.
Class initialization
new
:native-object
Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.
multi method new ( N-Object :$native-object! )
Methods
set-custom
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 Gnome::Gtk4::Image and Gnome::Gtk4::Label is embedded in the tooltip, which can be configured using .set-markup()
and .set-icon()
.
method set-custom ( N-Object() $custom-widget )
$custom-widget; a Gnome::Gtk4::Widget, or undefined to unset the old custom widget..
set-icon
Sets the icon of the tooltip (which is in front of the text) to be $paintable
. If $paintable
is undefined, the image will be hidden.
method set-icon ( N-Object() $paintable )
$paintable; a Gnome::Gdk4::R-Paintable.
set-icon-from-gicon
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 undefined, the image will be hidden.
method set-icon-from-gicon ( N-Object() $gicon )
$gicon; a Gnome::Gio::R-Icon representing the icon.
set-icon-from-icon-name
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 undefined, the image will be hidden.
method set-icon-from-icon-name ( Str $icon-name )
$icon-name; an icon name.
set-markup
Sets the text of the tooltip to be $markup
.
The string must be marked up with Pango markup. If $markup
is undefined, the label will be hidden.
method set-markup ( Str $markup )
$markup; a string with Pango markup or
NLL
.
set-text
Sets the text of the tooltip to be $text
.
If $text
is undefined, the label will be hidden. See also .set-markup()
.
method set-text ( Str $text )
$text; a text string.
set-tip-area
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 Gnome::Gtk4::TreeView rows and cells, GtkIconViews, etc.
For setting tooltips on Gnome::Gtk4::TreeView, please refer to the convenience functions for this: gtk_tree_view_set_tooltip_row() and gtk_tree_view_set_tooltip_cell().
method set-tip-area ( N-Object $rect )
$rect; a Gnome::Gdk4::N-Rectangle