Re: [Java-gnome-developer] OptionMenu events etc..
Brought to you by:
afcowie
From: Jonas B. <jb...@ni...> - 2003-10-05 09:17:38
|
On Sun, 05 Oct 2003 02:04:19 +0300, Jonas Berlin <jb...@ni...>= =20 wrote: > Now I suggest the following: > > 1. make sure all initializeEventHandlers() call=20 > super.initializeEventHandlers(), with the only exception being Widget,=20 > which is the topmost widget class. > 2. remove all <anywidgetclass>.addEvents() calls from the addEvents()=20 > methods of the various classes. > > This way, events should be registered only once, and as a bonus, the=20 > code will most likely be easier to read also =3D) > > I'll start working on a patch that will fix all widget classes accordin= g=20 > to my suggestion. If you have some better solution for this then I can=20 > try that as well :) Now I'm back a bit later with a patch according to the above suggestions,= =20 and additionally: 3. make the addEvents() methods private so nobody else can call them by=20 accident I tested the patch with the same Button & ToggleButton code I presented i= n=20 my last mail, and both now yield only one LifeCycleEvent. I didn't test=20 the other classes, but it's pretty simple a modification and I tried to=20 make sure I fixed them all the same way. Now then, the patch is here: http://xkr47.outerspace.dyndns.org/patches/java-gnome/cvs-031005-2-ini= tializeEvent-addEvents.diff The sourceforge cvs was inoperational, or at least I could not log in to=20 it and check out the project, so I did a dirty perl script that downloade= d=20 the entire java-gnome cvs through the cvsweb interface, which was still=20 operational. Thus, the patch is against the cvs version that was present=20 in sourceforge yesterday evening. Some final notes about the patch: - some classes had addEvents() methods that only called=20 <superclass>.addEvents(), which after my modification (2.) became empty,=20 so I removed those methods (and unnecessary EventMap imports that became=20 unnecessary) altogether. - some classes didn't have an addEvents() method at all, instead they d= id=20 what addEvents() used to do directly in the static { ... } block. I=20 thought consistency is bliss, created new addEvents() methods and moved=20 the code there. - xkr47 |