Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] How to add key event filter for an application?

Display.addFilter(..) can be used to listen for key events (like 
SWT.KeyDown) before the event reaches the widget hierarchy. I don't think 
the same functionality exists for mouse events. 

Note: if you are developing plugins for eclipse, you should know that 
eclipse itself uses this method to process its own key bindings. Using 
this method in this case would be strongly discouraged.

Chris.





Xiong Huan-a16898 <huan.xiong@xxxxxxxxxxxx> 
Sent by: platform-swt-dev-admin@xxxxxxxxxxx
11/12/2003 11:00 PM
Please respond to
platform-swt-dev


To

platform-swt-dev@xxxxxxxxxxx
cc





Subject
[platform-swt-dev] How to add key event filter for an application?






Hi,
 
Can I intercept key or mouse events before they are sent to widgets? I 
have checked API document and found Display class has addListener(int 
eventType, Listener listener) method. However, when I tried the following 
code snippet, it never got called at all when I pressed key. 
 
     display.addListener(SWT.KeyDown, new Listener() {
          public ovid handleEvent(Event e) {
               System.out.println("Hello, world!");
          }
     });
 
Can anybody throw some light on this problem? Thanks.
 
 




Back to the top