Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Use of Display.addFilter() in practice
Use of Display.addFilter() in practice [message #555509] Thu, 26 August 2010 21:05 Go to next message
Benjamin Gold is currently offline Benjamin GoldFriend
Messages: 6
Registered: July 2009
Junior Member
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 06:53 Go to previous messageGo to next message
Lakshmi P ShanmugamFriend
Messages: 279
Registered: July 2009
Location: India
Senior Member
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,


Lakshmi P Shanmugam
Re: Use of Display.addFilter() in practice [message #555576 is a reply to message #555509] Fri, 27 August 2010 09:02 Go to previous message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
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
Previous Topic:Being notified when other shell is being closed
Next Topic:Progress bar not progressing
Goto Forum:
  


Current Time: Thu Apr 25 06:39:44 GMT 2024

Powered by FUDForum. Page generated in 0.03093 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top