Tooltips for wxListCtrl column headers
-
- In need of some credit
- Posts: 9
- Joined: Mon May 03, 2021 12:20 pm
Tooltips for wxListCtrl column headers
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?
Re: Tooltips for wxListCtrl column headers
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.
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.
-
- In need of some credit
- Posts: 9
- Joined: Mon May 03, 2021 12:20 pm
Re: Tooltips for wxListCtrl column headers
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?
Re: Tooltips for wxListCtrl column headers
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.
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.
-
- In need of some credit
- Posts: 9
- Joined: Mon May 03, 2021 12:20 pm
Re: Tooltips for wxListCtrl column headers
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!
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!
Re: Tooltips for wxListCtrl column headers
Hi,
What version of wxWidgets do you use?
Thank you.
What version of wxWidgets do you use?
Thank you.
-
- In need of some credit
- Posts: 9
- Joined: Mon May 03, 2021 12:20 pm
Re: Tooltips for wxListCtrl column headers
I am using wxWidgets version 3.0.5.
Re: Tooltips for wxListCtrl column headers
Hi,
Try with the latest release (3.1.5).
Oe it was a typo?
Thank you.
Try with the latest release (3.1.5).
Oe it was a typo?
Thank you.
-
- In need of some credit
- Posts: 9
- Joined: Mon May 03, 2021 12:20 pm
Re: Tooltips for wxListCtrl column headers
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.
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.
Re: Tooltips for wxListCtrl column headers
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!