Package org.gnome.gtk
Class Tooltip
java.lang.Object
org.javagi.base.ProxyInstance
org.gnome.gobject.TypeInstance
org.gnome.gobject.GObject
org.gnome.gtk.Tooltip
- All Implemented Interfaces:
Proxy
Represents 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-tooltipproperty 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-tooltipsignal. This signal will be emitted when a tooltip is supposed to be shown. One of the arguments passed to the signal handler is aGtkTooltipobject. 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
truefrom your ::query-tooltip handler. This causes the tooltip to be show. If you returnfalse, it will not be shown.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classTooltip.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
ConstructorsConstructorDescriptionTooltip()Creates a new Tooltip.Tooltip(MemorySegment address) Create a Tooltip proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected TooltipasParent()Returns this instance as if it were its parent type.static Tooltip.Builder<? extends Tooltip.Builder> builder()ATooltip.Builderobject constructs aTooltipwith the specified properties.static @Nullable TypegetType()Get the GType of the Tooltip classvoidReplaces the widget packed into the tooltip withcustomWidget.customWidgetdoes not get destroyed when the tooltip goes away.voidSets the icon of the tooltip (which is in front of the text) to bepaintable.Ifpaintableisnull, the image will be hidden.voidsetIconFromGicon(@Nullable Icon gicon) Sets the icon of the tooltip (which is in front of the text) to be the icon indicated bygiconwith the size indicated bysize.Ifgiconisnull, the image will be hidden.voidsetIconFromIconName(@Nullable String iconName) Sets the icon of the tooltip (which is in front of the text) to be the icon indicated byiconNamewith the size indicated bysize.IficonNameisnull, the image will be hidden.voidSets the text of the tooltip to bemarkup.voidSets the text of the tooltip to betext.voidsetTipArea(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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.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
-
Tooltip
public Tooltip()Creates a new Tooltip.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, 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.customWidgetdoes not get destroyed when the tooltip goes away. By default a box with aGtkImageandGtkLabelis embedded in the tooltip, which can be configured using gtk_tooltip_set_markup() and gtk_tooltip_set_icon().- Parameters:
customWidget- aGtkWidget, ornullto unset the old custom widget.
-
setIcon
Sets the icon of the tooltip (which is in front of the text) to bepaintable.Ifpaintableisnull, 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 bygiconwith the size indicated bysize.Ifgiconisnull, the image will be hidden.- Parameters:
gicon- aGIconrepresenting the icon
-
setIconFromIconName
Sets the icon of the tooltip (which is in front of the text) to be the icon indicated byiconNamewith the size indicated bysize.IficonNameisnull, 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
markupisnull, the label will be hidden.- Parameters:
markup- a string with Pango markup orNLL
-
setText
Sets the text of the tooltip to betext.If
textisnull, 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 onGtkTreeViewrows 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.Builderobject constructs aTooltipwith the specified properties. Use the variousset...()methods to set properties, and finish construction withTooltip.Builder.build().- Returns:
- the builder object
-