[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] How to get the focus of a Canvas
|
I'm programming a project with modular shells. It means something in the
way of Gimp - one main window and a couple of shells if you need it.
Now I have the problem that one shell containes a canvas where I have to
know when the mouse enters the canvas. So I thought FocusListener is what
I'm looking for, but it doesn't work.
Snippet 1:
mycanvas.addListener(SWT.FocusIn, new Listener(){
public void handleEvent(Event event) {
System.out.println("test");
}
});
does not recognize anything, when I enter with the mouse pointer.
Snippet 2:
mycanvas.addFocusListener(new FocusListener(){
public void focusGained(FocusEvent e) {
System.out.println("test");
}
});
also ignores every mouseover-event.
Snippet 3:
Display display = this.mycanvas.getDisplay();
display.addFilter(SWT.FocusIn, new Listener(){
public void handleEvent(Event event) {
System.out.println("text");
}
});
This version shows me at least something. More exactly I get a message if
the mouse pointer enters the area of the main window, but it ignores every
mouseover-event of the windows where the Canvas is included.
A really sick idea could be the use of a MouseMoveListener, but I don't
know how to realize when the Canvas loses the focus.
How can I get a signal when entering the Canvas?