0

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.

Baz
  • 36,440
  • 11
  • 68
  • 94

3 Answers3

3

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.

greg-449
  • 109,219
  • 232
  • 102
  • 145
3

While you can implementet text hover yourself, with a MouseTrackListener like suggested by Greg, you can also use the JFace TextViewer.

The TextViewer provides a higher-level abstraction for text hover. With its setTextHover() methods you can set a callback, that is informed when a text hover for a certain region should be shown.

This is also the method that is used by Eclipse text editors.

Community
  • 1
  • 1
RĂ¼diger Herrmann
  • 20,512
  • 11
  • 62
  • 79
0

I believe those are tooltips that appear when you hover over a text for e.g. in Java editor. See here for tooltip doc and here for examples on how real production code uses eclipse tooltips.

SomeDude
  • 13,876
  • 5
  • 21
  • 44