views:

416

answers:

2

Hi all,

I have a tiny (rikiki) problem in SWT ...

I am making a small class extending org.eclipse.swt.widgets.Composite and which is supposed to be nested in an RCP app ...

In this small class I have widgets which are supposed to react to mouse or keyboard event

BUT

I need to use modifier keys (Shift/Ctrl/Alt/...) to alter my coponents behaviours when I click them or send them keyboard event ...

The probleme is that I cannot just listen for mod-key striking because my user can strike it out from my component and then click it...

I cannot use a display filter to avoid disturbing the shell that nests my component.(but may be it will be my last solution in case there is no other solution)

I cannot make a transparent component that reads and dispatch events to all of my components because it would, at the most, be as large as my component and wont get mod-key strikes from the shell out my component (or even out from the shell) ...

Do anyone have any idea?

+1  A: 

Try something along these lines to capture all keys and save them for later:

 Display.getDefault().addFilter( SWT.KeyDown, new Listener() {

  public void handleEvent( Event passedEvent ) {
   //Listen for and store as static var last pressed keycode
   System.out.println( "Key Event: " + passedEvent );
  }
 } );
fisherja
Yes but it captures all the key press, even the un-necessary ones ...My State-Mask method (getting de modifier key pressed when you trigger another event) is much simpler ^^ (in my case at least)
Ar3s
For completeness could you post your method/solution to this question as well? Thanks
fisherja
+1  A: 
Ar3s