Package org.gnome.gtk
Class Tooltip
- All Implemented Interfaces:
Proxy
GtkTooltip
is an object representing a widget tooltip.
Basic tooltips can be realized simply by using
Widget.setTooltipText(java.lang.String)
or
Widget.setTooltipMarkup(java.lang.String)
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 GtkTreeView
row or cell, you will have to do a
little more work:
- Set the
Gtk.Widget:has-tooltip
property totrue
. 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
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 aGtkTooltip
object. This is the object that we are about to display as a tooltip, and can be manipulated in your callback using functions likesetIcon(org.gnome.gdk.Paintable)
. 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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Tooltip.Builder<B extends Tooltip.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionTooltip
(MemorySegment address) Create a Tooltip proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected Tooltip
asParent()
Returns this instance as if it were its parent type.static Tooltip.Builder
<? extends Tooltip.Builder> builder()
ATooltip.Builder
object constructs aTooltip
with the specified properties.static Type
getType()
Get the GType of the Tooltip classvoid
Replaces the widget packed into the tooltip withcustomWidget
.void
Sets the icon of the tooltip (which is in front of the text) to bepaintable
.void
setIconFromGicon
(@Nullable Icon gicon) Sets the icon of the tooltip (which is in front of the text) to be the icon indicated bygicon
with the size indicated bysize
.void
setIconFromIconName
(@Nullable String iconName) Sets the icon of the tooltip (which is in front of the text) to be the icon indicated byiconName
with the size indicated bysize
.void
Sets the text of the tooltip to bemarkup
.void
Sets the text of the tooltip to betext
.void
setTipArea
(Rectangle rect) Sets the area of the widget, where the contents of this tooltip apply, to berect
(in widget coordinates).Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Tooltip
Create a Tooltip proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
setCustom
Replaces the widget packed into the tooltip withcustomWidget
.customWidget
does not get destroyed when the tooltip goes away. By default a box with aGtkImage
andGtkLabel
is embedded in the tooltip, which can be configured using gtk_tooltip_set_markup() and gtk_tooltip_set_icon().- Parameters:
customWidget
- aGtkWidget
, ornull
to unset the old custom widget.
-
setIcon
Sets the icon of the tooltip (which is in front of the text) to bepaintable
. Ifpaintable
isnull
, the image will be hidden.- Parameters:
paintable
- aGdkPaintable
-
setIconFromGicon
Sets the icon of the tooltip (which is in front of the text) to be the icon indicated bygicon
with the size indicated bysize
. Ifgicon
isnull
, the image will be hidden.- Parameters:
gicon
- aGIcon
representing the icon
-
setIconFromIconName
Sets the icon of the tooltip (which is in front of the text) to be the icon indicated byiconName
with the size indicated bysize
. IficonName
isnull
, the image will be hidden.- Parameters:
iconName
- an icon name
-
setMarkup
Sets the text of the tooltip to bemarkup
.The string must be marked up with Pango markup. If
markup
isnull
, the label will be hidden.- Parameters:
markup
- a string with Pango markup orNLL
-
setText
Sets the text of the tooltip to betext
.If
text
isnull
, the label will be hidden. See alsosetMarkup(java.lang.String)
.- Parameters:
text
- a text string
-
setTipArea
Sets the area of the widget, where the contents of this tooltip apply, to berect
(in widget coordinates). This is especially useful for properly setting tooltips onGtkTreeView
rows and cells,GtkIconViews
, etc.For setting tooltips on
GtkTreeView
, please refer to the convenience functions for this: gtk_tree_view_set_tooltip_row() and gtk_tree_view_set_tooltip_cell().- Parameters:
rect
- aGdkRectangle
-
builder
ATooltip.Builder
object constructs aTooltip
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withTooltip.Builder.build()
.
-