RE: [Java-gnome-hackers] Handling Events in java-gnome
Brought to you by:
afcowie
From: Philip A. C. <pc...@td...> - 2002-08-13 13:27:52
|
On Tue, 2002-08-13 at 07:29, Jeffrey Morgan wrote: > Sorry for taking so long replying to the list. I had a=20 > family emergency Friday night that has occupied all of=20 > my time until now. I think using a container of=20 > WeakReferences is a good idea.=20 I hope everything is OK now. Thanks for your vote of confidence on using WeakReferences. > I think we should try to model our events after the standard > java event model. We need to be careful with the events > we expose. For example, for GtkWidget there are over 50 > signals/events. This could easily create a very complex > implementation. My suggestion is to only expose the events > that a user of the bindings might be interested in. Also, > if there are related events combine the notification into > a single method passing an indicator to identify which event > has occurred. I agree. As you say, we could probably lump a lot of similar events into a single method for the listener interface. With this many events, it's probably not a good idea to create a parent event and subclass it for each individual type. We could probably get away with a type property in the event and an enumeration of what those types can be.=20 The downside is that the event model would get very "chatty" as the listener will be called many different times for many different events types when it only wants a particular type. May I suggest that each event have a type field whos value is a long.=20 The enumeration would be bitflags. When the listener registers, it indicates which specific event types it wants to listen to in the form of a long value. That way the notifier will only call the event for listeners which request it. Thanks, > To server as an example of this I hope to complete gtk.Widget > today. >=20 > -Jeff --=20 Philip A. Chapman |