Creating a tooltip programmatically at a certain screen position

10 views
Skip to first unread message

Gonzalo Garramuño

unread,
Oct 25, 2025, 7:00:49 PMOct 25
to fltkg...@googlegroups.com
Title explains it better.  I would like to create a tooltip window that
is not associated to any FLTK Widget (it will follow a Vulkan widget).
How can I do that easily?

--
ggar...@gmail.com

Matthias Melcher

unread,
Oct 25, 2025, 8:49:47 PMOct 25
to fltk.general
You can create a non_moda()l window. It will hover above any of your application windows without blocking event delivery. Make it borderless() and use position() to make it follow your mouse pointer if that's what you want. Fl::event_x_root()/event_y_root() gives you the mouse position in global coordinates during events. To make your window behave more like the original, there are also Fl_Window::set_tooltip_window() and set_menu_window() that are used to give the desktop driver additional indication for what the window is used.

There is of course the source code for in Fl_TooltipBox src/Fl_Tooltip.cxx that show how the original tooltip is implemented. It has additional timers ans monitors the mouse. 

Matthias Melcher

unread,
Oct 25, 2025, 8:53:43 PMOct 25
to fltk.general
Oh, and you can also get the FL_BEFORE_TOLTIP event for any widget. It gives you the opportunity to change the tooltip before it is displayed. For example, you have a 3d scene in a graphics window, and the user hovers the mouse, triggering a tooltip. You can now use FL_BEFORE_TOLTIP to change the text in the tooltip window to the mouse coordinates, for example.
Reply all
Reply to author
Forward
0 new messages