views:

609

answers:

3
A: 

Paul,

try using addMouseEvent method from a Scrollable object. For example:

Scrollable scrollable = scrollbar.getParent();
scrollable.addMouseListener(new MouseListener () {
   void mouseDoubleClick(MouseEvent e) { ... }
   void mouseDown(MouseEvent e) { ... }
   void mouseUp(MouseEvent e)  { ... }
});

Actually, I don't know if this approach will work. But, it's an attempt. Good luck!

nandokakimoto
Good suggestion, thanks. This simply resolves back to the ScrolledComposite, however, which only responds to the events within the composite itself, not in the scrollbars.
Paul Lammertsma
+1  A: 

Scrollbar's javadoc said this:

When widgetSelected is called, the event object detail field contains one of the following values: SWT.NONE - for the end of a drag. SWT.DRAG. SWT.HOME. SWT.END. SWT.ARROW_DOWN. SWT.ARROW_UP. SWT.PAGE_DOWN. SWT.PAGE_UP. widgetDefaultSelected is not called.

So my suggestion is get your tooltip to appear and disappear is to check for the event.detail type.

public void widgetSelected(SelectionEvent event) {
    tip.setVisible(event.detail != SWT.NONE);
}
DJ
Excellent! I'll take a look to see if this suffices first thing in the morning.
Paul Lammertsma
Works like a charm! Thank you very much!
Paul Lammertsma
+3  A: 
scrollBar.addSelectionListener(new SelectionListener() {
    public void widgetDefaultSelected(SelectionEvent e) {
    }

    public void widgetSelected(SelectionEvent e) {
     if (e.detail == SWT.NONE) {
      // end of drag
      System.out.println("Drag end");
     }
     else if (e.detail == SWT.DRAG) {
      // drag
      System.out.println("Currently dragging");
     }
    }
});

Hope this will help you... But I can see a problem with mousewheel use that throws multiple drag end events...

Arnaud