2

The exact already asked question to what I'd like to do is: how to add tooltip on the entries and not the combo....

I cannot use a CCombo. JoeYo said that he solved it by using a DefaultToolTip class on the Combo, but he didn't elaborate.

Can anyone, (@JoeYo hopefully) give me a bit more detail how to got the handle on the list, once dropped, to capture the mouse hover events, and then of course display the tool tip?

If I was supposed to ask for more info on the original question, I could not figure out how. I tried to comment, but was told I did not have enough credits.

Community
  • 1
  • 1
Steve
  • 25
  • 3

1 Answers1

1

DefaultToolTip is part of JFace. Other than the native tooltip of the platform, it can be freely positioned and shown/hidden. Internally it is comprised of a Shell that when shown stays on top of all other controls.

In combination with a MouseListener, the getVisibleItemCount() and getItemHeight you might be able to compute above which item (if any) the mouse cursor hovers and show a tooltip with suitable content.

This answer has a snippet that computes which item of a List widget is under the mouse pointer. It should be possible to adapt it for the Combo widget. The remaining difficulty is probably to figure out the of the drop-down and the gap between of the Combo and its drop-down.

Community
  • 1
  • 1
Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
  • Accepted as a reasonable solution. Did not work in my case however. The docs for getVisibleItemCount() say that this method may not work on all platforms. In my case, (Win 7), I always got a returned value of 23. I tried on a few different Combos, and always got 23, and of course there we never 23 items. The tool tip was not an absolute requirement, so I decided to move on. Thanks for the suggestion Rüdiger. – Steve Feb 06 '15 at 13:02