tooltips for menu items

19 views
Skip to first unread message

Paul Hahn

unread,
Aug 12, 2022, 11:15:05 AM8/12/22
to fltk.general

Is there a way to have tooltips for one (all) menu items in an Fl_Menu_? More specifically, I have an instance of Fl_Choice (parent class is Fl_Menu_) and I would like to show tooltips for the selection items.

Is subclassing Fl_Choice and doing the work to implement some kind of "tooltip" in its handle() method override really the only way?

If it is, any suggestion on that implementation so the "tooltips" look and operate consistent with the usual FLTK widget tooltips?

imm

unread,
Aug 13, 2022, 6:02:31 AM8/13/22
to General FLTK
Hi Paul

The problem is that (for historical reasons that were good choices at the time) menu items are not true widgets (in the fltk sense) and so have no means to readily utilize the tooltip mechanism.

The issue with menu items not being widgets is one of those things that keeps coming round to bite us...

And I don't have a workaround for menu tooltips - though someone else may?

--
Ian
From my Fairphone FP3

lifeatt...@gmail.com

unread,
Aug 13, 2022, 7:42:35 PM8/13/22
to fltk.general
The edeproject has an old Github repository, where their efltk includes tooltip support for menu items. I _think_ the code is FLTK 2.0 based or possible 1.1.


>>Is there a way to have tooltips for one (all) menu items in an Fl_Menu_?

imm

unread,
Aug 14, 2022, 1:28:26 PM8/14/22
to General FLTK
On Sun, 14 Aug 2022, 00:42 lifeatt.. wrote:
The edeproject has an old Github repository, where their efltk includes tooltip support for menu items. I _think_ the code is FLTK 2.0 based or possible 1.1.

I think it was fltk-2, though can't really remember (and have not checked!)

One of the innovations in fltk-2 was to make menu items full widgets, for exactly this sort of reason.

The fltk-2 API is quite different from fltk-1 and so porting isn't always trivial...

Bill Spitzak

unread,
Aug 14, 2022, 7:22:55 PM8/14/22
to fltkg...@googlegroups.com
Yes fltk-2 made all the menu and browser items into widgets, allowing them to all have their own boxtype, color, font, etc as well as their own drawing functions if you used a subclass. Incompatibility with fltk1 was a big problem though.


--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/CAGFM6dabk%2BysGkp922U2q8x2FuDo7vpvOP%3DQZtuJxPs-fGSrbA%40mail.gmail.com.

Sanel Zukan

unread,
Aug 16, 2022, 1:02:49 PM8/16/22
to lifeatt...@gmail.com, fltk.general
EDE 2.x (built with FLTK 1.x) has tooltip support inside menus, but I
had to "fork" Fl_Menu_Item to add support for it, mainly because
Fl_Menu_Item is hard to extend.

See MenuTooltip.h [1] and how is called in MenuItem.cpp
(Fl_Menu_Item.cpp fork) [2][3]. It is very easy and unobtrusive to add it
inside the existing Fl_Menu_Item.cpp code, so the current FLTK
maintainers might consider the same (or a similar) approach.

[1] https://github.com/edeproject/edelib/blob/master/edelib/MenuTooltip.h
[2] https://github.com/edeproject/edelib/blob/05edc0cc5d651234bbe9887d6e9ec5ffe0bb829e/src/MenuItem.cpp#L185
[3] https://github.com/edeproject/edelib/blob/05edc0cc5d651234bbe9887d6e9ec5ffe0bb829e/src/MenuItem.cpp#L540

Best,
Sanel
Reply all
Reply to author
Forward
0 new messages