Thayne
Thayne

Reputation: 7002

How can I get a tooltip to appear above a widget instead of below with gtk4

I have widgets at the bottom of the screen that have tooltips. I'd like to tell gtk that I would prefer these tooltips to be shown above the widget instead of below the widget. In my case the tooltips are actually going off screen (which I think may partly be due to a bug in sway, but that's kind of beside the point).

Is there any way that I can control which direction the tooltip is drawn with respect to the original widget?

Upvotes: 1

Views: 54

Answers (1)

Holger
Holger

Reputation: 1020

I suggest using a GtkTooltip Object here and then use it with

void
gtk_tooltip_set_tip_area (
  GtkTooltip* tooltip,
  const GdkRectangle* rect
)

https://docs.gtk.org/gtk4/method.Tooltip.set_tip_area.html

" 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 GtkTreeView rows and cells, GtkIconViews, etc. "

Have fun programming.

Upvotes: 0

Related Questions