This is the mail archive of the kawa@sourceware.cygnus.com mailing list for the Kawa project. See the Kawa home page for more information.
On Tue, 13 Oct 1998, Per Bothner wrote: > A goal of Kawa is to make it easy to mix Java and Scheme, including > accessing Java packages from Scheme. One need is to be able to > write Java Event call-backs in Scheme. I haven't tried this myself, > but I suspect it is somewhat clumsy, requiring extra Java glue code > to be written. I've tried to come up with a Scheme-only approach > that is compact, efficient, and general. What do people (especially > those with actual kawa/AWT programming experience) think of the > following design? > > Syntax: (listener (EXTRA-INTERFACE ...) > ((METHOD-NAME+ [EVENT-TYPE])+ ARG ACTION ...) ...) > > Example: (invoke component 'addMouseListener > (listener ((mousePressed mouseReleases) evt > (display (list "mouse pressed or released:" evt)))) > > [Note: the invoke procedure used is purely for the sake of this example.] > > This creates a new "listener" instance. The instance has one > method for each METHOD-NAME; the method takes a single argument > of the specified EVENT-TYPE. The EVENT-TYPE can be left out > in the case of standard java METHOD-NAMES; for example > if the METHOD-NAME is mousePressed, the implied EVENT-TYPE > is <java.awt.event.MouseEvent>. When the method is executed, > the actual Event is bound to ARG, and the ACTIONs executed. > (The type is ARG is the lowest common super-type of all > the explicit or implicit EVENT-TYPES for corresponding METHOD-NAMES.) > The allocated listener instance implements all the interfaces > listed in the EXTRA-INTERFACE list; if addition, if an EVENT-TYPE > was implied, the corresponding Listener interface is also implied. > For example a METHOD-NAME of mousePressed implies an EVENT-TYPE > of <java.awt.event.MouseEvent>, and hence an interface of > <java.awt.event.MouseListener>. Hey, Per. I implemented a Java 1.1 style event system using Java glue code (I subclassed Applet, Canvas, and a few other AWT components). This worked fine for applications, but the Java 1.1 standard isn't well supported in the browser world yet. I ended up going back to a Java 1.0 (non-listener) based system. I don't know how many Kawa users are building applets (I may be the only one) but it may be worth thinking about. Perhaps more importantly, listeners have to be registered with a particular AWT component (two different components in the same application may handle the same event very differently) so there will need to be some way of specifying which. Rich Richard W. DeVaul What do I rich@media.mit.edu Home: (617) 623-5849 see with my I? Lab: (617) 253-9706 www--> http://www.media.mit.edu/~rich/ <--www