SWT Problem with MouseTrackListener and Shell

Posted by Krt_Malta on Stack Overflow See other posts from Stack Overflow or by Krt_Malta
Published on 2010-03-11T16:27:34Z Indexed on 2010/03/12 15:57 UTC
Read the original article Hit count: 269

Filed under:
|

Hi!

I'm developing an Eclipse plug-in and I have a problem which is reproduced in this small SWT application:

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Text text = new Text(shell, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL);
    text.setText("Hello");
    shell.setLayout(new FillLayout());
    shell.addMouseTrackListener(new MouseTrackListener() {

      public void mouseEnter(MouseEvent arg0) {
        System.out.println("mouseEnter");

      }

      public void mouseExit(MouseEvent arg0) {
        System.out.println("mouseExit");

      }

      public void mouseHover(MouseEvent arg0) {
        System.out.println("mouseHover");

      }
    });
    // Display the window
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  } 

As you can see I'm creating a shell and putting a Textbox inside it and putting it all across the shell. Then I attach a MouseTrackListener to the shell. The events don't fire (as in when I hover in the shell "mouseHover" is not printed etc). When I remove the Textbox the events fire. Can anyone tell me where the problem lies please? I don't want to attach a listener to the textbox but to the shell. I'll really appreciate the help because I've been trying to trace it for quite some time now.

Thanks and regards, Krt_Malta

© Stack Overflow or respective owner

Related posts about swt

Related posts about eclipse