|
|
Re: Events not passed up to Shell? [message #453913 is a reply to message #453912] |
Wed, 13 April 2005 18:08 |
Emil Crumhorn Messages: 169 Registered: July 2009 |
Senior Member |
|
|
Wops, got too much code in there, here's the right one. Typed it from
keyboard =p
Display.getDefault().addFilter(SWT.KeyDown, new Listener() {
public void handleEvent(Event event) {
// do your thing
}
}
"Emil Crumhorn" <crumhorn@speakeasy.net> wrote in message
news:d3jngg$om6$1@news.eclipse.org...
> Add the keylistener to the Display as a filter. Here's how (can change out
> Display.getDefault() to your display if you want):
>
> Display.getDefault().display.addFilter(SWT.KeyDown, new Listener() {
> public void handleEvent(Event event) {
> // do your thing
> }
> }
>
> This will fire for any sub-shell as well, if you have multiple shells and
> only want a particular shell, just see what shell is being fired by
> fetching getActiveShell() from the display object to see what shell is
> which.
>
> Emil
>
>
> "Bill Hutten" <bill@hutten.org> wrote in message
> news:bill-877B28.12291313042005@news.eclipse.org...
>>
>> I have a simple Shell with a few widgets on it. I'd like to add a
>> KeyListener to the shell to intercept all keyboard events, regardless of
>> whether any particular widget has focus.
>>
>> Unfortunately, this doesn't seem to be working. Adding a listener to a
>> widget works fine, of course, but if a widget has focus and does not
>> have a listener then the Shell listener does not get the event...
>>
>> Is there any way to make this work? Attaching a duplicate listener to
>> each widget just to handle a particular keystroke seems a little
>> stupid....
>>
>>
>>
>> - bill
>> --
>> bill@hutten.org
>
>
|
|
|
Re: Events not passed up to Shell? [message #453917 is a reply to message #453913] |
Wed, 13 April 2005 21:35 |
Eclipse User |
|
|
|
Originally posted by: bob.objfac.com
The filter gets called first, before any component gets to see the key?
Bob Foster
Emil Crumhorn wrote:
> Wops, got too much code in there, here's the right one. Typed it from
> keyboard =p
>
> Display.getDefault().addFilter(SWT.KeyDown, new Listener() {
> public void handleEvent(Event event) {
> // do your thing
> }
> }
>
> "Emil Crumhorn" <crumhorn@speakeasy.net> wrote in message
> news:d3jngg$om6$1@news.eclipse.org...
>
>>Add the keylistener to the Display as a filter. Here's how (can change out
>>Display.getDefault() to your display if you want):
>>
>>Display.getDefault().display.addFilter(SWT.KeyDown, new Listener() {
>> public void handleEvent(Event event) {
>> // do your thing
>> }
>>}
>>
>>This will fire for any sub-shell as well, if you have multiple shells and
>>only want a particular shell, just see what shell is being fired by
>>fetching getActiveShell() from the display object to see what shell is
>>which.
>>
>>Emil
>>
>>
>>"Bill Hutten" <bill@hutten.org> wrote in message
>>news:bill-877B28.12291313042005@news.eclipse.org...
>>
>>>I have a simple Shell with a few widgets on it. I'd like to add a
>>>KeyListener to the shell to intercept all keyboard events, regardless of
>>>whether any particular widget has focus.
>>>
>>>Unfortunately, this doesn't seem to be working. Adding a listener to a
>>>widget works fine, of course, but if a widget has focus and does not
>>>have a listener then the Shell listener does not get the event...
>>>
>>>Is there any way to make this work? Attaching a duplicate listener to
>>>each widget just to handle a particular keystroke seems a little
>>>stupid....
>>>
>>>
>>>
>>>- bill
>>>--
>>>bill@hutten.org
>>
>>
>
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02852 seconds