Tooltips for wxListCtrl column headers

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
randomuser
In need of some credit
In need of some credit
Posts: 5
Joined: Mon May 03, 2021 12:20 pm

Tooltips for wxListCtrl column headers

Post by randomuser » Fri May 14, 2021 9:52 am

Hi. I'd like to provide a tooltip for each column of a wxListCtrl when the mouse hovers over a column header. The text needs to be different for each column and there should be no tooltip for items. I was only able to add a tooltip to the whole wxListCtrl. I found an older thread discussing a related issue and it was suggested to change the text on mouse events: viewtopic.php?f=1&t=13179&p=58922. Unfortunately, I can't figure out how to do that since wxListCtrl doesn't seem to emit anything like a "hover" or "mouseover" event. I also worry that there might be performance implications of changing the tooltip text whenever the mouse moves. Could someone elaborate or provide an alternate solution?

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5156
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Tooltips for wxListCtrl column headers

Post by ONEEYEMAN » Fri May 14, 2021 11:49 am

Hi,
I don't think you can do that.
wxWidgets using native controls whenever possible and on Windows the control doesn't support this feature.

Sorry.

Thank you.

randomuser
In need of some credit
In need of some credit
Posts: 5
Joined: Mon May 03, 2021 12:20 pm

Re: Tooltips for wxListCtrl column headers

Post by randomuser » Fri May 14, 2021 12:56 pm

Does this limitation only apply to wxListCtrl, or is this also the case for other widgets that can display lists, such as wxTreeCtrl and wxDataViewCtrl?

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5156
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Tooltips for wxListCtrl column headers

Post by ONEEYEMAN » Fri May 14, 2021 1:42 pm

Hi,
Not for just the header, no.
For the tree you can set to individual branches or the control itself.
Not sure about wxDVC.

Thank you.

randomuser
In need of some credit
In need of some credit
Posts: 5
Joined: Mon May 03, 2021 12:20 pm

Re: Tooltips for wxListCtrl column headers

Post by randomuser » Fri May 14, 2021 4:11 pm

That's unfortunate, but thank you for answering.

I decided to work around the issue for now by binding to the wxEVT_MOTION event (which wxListCtrl emits because of inheriting from some superclass), checking if the x-position of the mouse cursor is inside any column (with wxListCtrl::GetSubItemRect and wxMouseEvent::GetLogicalPosition), and setting/unsetting the tooltip text accordingly.

With this workaround, the tooltip still doesn't show while hovering over the column header (at least with gtk2) and doesn't work with empty tables, but it's good enough for my purposes.

Thanks!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5156
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Tooltips for wxListCtrl column headers

Post by ONEEYEMAN » Fri May 14, 2021 4:27 pm

Hi,
What version of wxWidgets do you use?
Thank you.

randomuser
In need of some credit
In need of some credit
Posts: 5
Joined: Mon May 03, 2021 12:20 pm

Re: Tooltips for wxListCtrl column headers

Post by randomuser » Fri May 14, 2021 4:43 pm

I am using wxWidgets version 3.0.5.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5156
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Tooltips for wxListCtrl column headers

Post by ONEEYEMAN » Fri May 14, 2021 5:05 pm

Hi,
Try with the latest release (3.1.5).
Oe it was a typo? ;-)

Thank you.

randomuser
In need of some credit
In need of some credit
Posts: 5
Joined: Mon May 03, 2021 12:20 pm

Re: Tooltips for wxListCtrl column headers

Post by randomuser » Fri May 14, 2021 6:10 pm

It was not a typo. I am very new to wxWidgets, so I thought 3.1.5 (the newest development release) would be less stable than 3.0.5 (the newest stable release). Is this not the case?

Anyway, I tried it with 3.1.5 as well, and the behaviour is the same as in 3.0.5.

I should also clarify: The tooltip does show when hovering over the header, but the wxEVT_MOTION event only triggers when moving the mouse in the item area. It doesn't trigger when moving the mouse over the header, so I can't set the tooltip text to the correct text.

User avatar
doublemax
Moderator
Moderator
Posts: 16022
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Tooltips for wxListCtrl column headers

Post by doublemax » Fri May 14, 2021 7:44 pm

Depending on what you need to display, and how important the column tooltips are for you, wxGrid might be another option. It can be configured to use a non-native header, so i'm pretty sure you can receive EVT_MOTION events from it.
Use the source, Luke!

Post Reply