javaswtmousehoverstyledtext

How to show a hover popup with SWT StyledText


I am using SWT's StyledText and I am wondering how I would detect if the user hovers over a word for more then 3 seconds. An example of what I mean is how Eclipse has a popup that shows, when you hover over a text.


Solution

  • You can use a 'mouse track listener' to listen for mouse hover events. However you can't set the hover time for this:

    control.addMouseTrackListener(MouseTrackListener)
    

    MouseTrackListener has three events - mouseEnter, mouseExit and mouseHover.