Custom Event Type [message #644746] |
Mon, 13 December 2010 23:56  |
Eclipse User |
|
|
|
Hi,
I would like to create a custom event type.
This custom type should create a new integer constant which will be used in addListener and also notifyListeners.
e.g.
public static final int MY_EVENT = 0x1000;
...
someComposite.notifyListeners(MY_EVENT, new Event());
Is there a standard way to create a new custom event type?
Any replies on this topic will be appreciated.
|
|
|
Re: Custom Event Type [message #645068 is a reply to message #644746] |
Wed, 15 December 2010 08:45  |
Eclipse User |
|
|
|
Hi,
When you create your own Event id and reuse the SWT event mechanism for it, its possible that the event id will be used by SWT in future and then there will be a clash.
If you are creating your own wiget/composite, you can create custom events and listeners. Please take a look at the Custom events in SWT such as LocationEvent, TitleEvent. and WebBrowser.addLocationListener(), WebBrowser.addTitleListener.
1) create custom event by extending TypedEvent.
2) create listener interface by extending EventListener
Also, please see this article for a discussion on events and listeners for custom widgets--> http://www.eclipse.org/articles/Article-Writing%20Your%20Own %20Widget/Writing%20Your%20Own%20Widget.htm
HTH,
|
|
|
Powered by
FUDForum. Page generated in 0.15756 seconds