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.
Asked
Active
Viewed 617 times
0

Baz
- 36,440
- 11
- 68
- 94

ThePrimedTNT
- 85
- 7
3 Answers
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