Use of Display.addFilter() in practice [message #555509] |
Thu, 26 August 2010 17:05  |
Eclipse User |
|
|
|
The JavaDoc for Display.addFilter() indicates that filters "should generally be avoided for performance, debugging and code maintenance reasons". How much of a performance impact is say, a KeyUp Filter, on an enterprise application which is likely to receive lots of keyboard events?
Is there an alternative to adding a Display filter if you need a Shell level keyboard listener, for something like keyboard shortcuts? If possible I would scope it to individual Shells but I don't see any way to do that (normal keyboard listeners don't get events from children UI elements).
As an additional aside, are there any plans to change the Command-W behavior on a Mac, or at least to allow some sort of customizable behavior? Closing individual editor windows makes sense in an IDE, but not as much sense in a multiple window RCP application and it would be nice to have the correct platform behavior.
|
|
|
Re: Use of Display.addFilter() in practice [message #555547 is a reply to message #555509] |
Fri, 27 August 2010 02:53   |
Eclipse User |
|
|
|
Hi,
When you add say a KeyUp filter to the Display, you'll be notified of a KeyUp event happening on any widget belonging to this Display and the Listener code will be executed each time. So, the performance impact is only because your listener code runs on every/any KeyUp event. But, when you add a listener to a widget, you'll listener code runs only when the event happens on your widget.
If you are interested in the listening to the events only on a particular shell, you can try if this works for you. Add the filter when the shell is activated and remove it once the shell is deactivated. So, you'll notified only when KeyUp events happen in your shell.
shell.addShellListener(new ShellAdapter() {
public void shellActivated(ShellEvent e) {
display.addFilter(SWT.KeyUp, listener);
}
public void shellDeactivated(ShellEvent e){
display.removeFilter(SWT.KeyUp, listener);
}
});
For the last part of your question, I think you can customize the command+W behavior on Mac for your RCP application, please ask this question in the Platform UI forum to get the right answer.
HTH,
|
|
|
Re: Use of Display.addFilter() in practice [message #555576 is a reply to message #555509] |
Fri, 27 August 2010 05:02  |
Eclipse User |
|
|
|
On 27/08/10 2:35 AM, Benjamin Gold wrote:
> As an additional aside, are there any plans to change the Command-W
> behavior on a Mac, or at least to allow some sort of customizable
> behavior? Closing individual editor windows makes sense in an IDE, but
> not as much sense in a multiple window RCP application and it would be
> nice to have the correct platform behavior.
This is already customizable. In your RCP, you can create your own key
binding scheme and associate the keys and commands in the way you want.
- Prakash
Platform UI Team, IBM
www.eclipse-tips.com
|
|
|
Powered by
FUDForum. Page generated in 0.23977 seconds