home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!ames!data.nas.nasa.gov!taligent!apple!apple!cambridge.apple.com!bill@cambridge.apple.com
- From: bill@cambridge.apple.com (Bill St. Clair)
- Newsgroups: comp.lang.lisp.mcl
- Subject: Re: Multiple events
- Message-ID: <9209141614.AA23046@cambridge.apple.com>
- Date: 14 Sep 92 17:22:26 GMT
- Sender: info-mcl-request@cambridge.apple.com
- Lines: 60
- Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
- Full-Name: Bill St. Clair
- Original-To: jipan@gmuvax2.gmu.edu (Jiqian Pan)
- Original-Cc: info-mcl
-
- >Hi, MCL Experts:
- >
- >Here are some funny things about other events when a WHILE function
- >is called inside a method and in Listener. Their code is:
- >
- >(defclass my-window (window) ())
- >
- >(setf foo (make-instance 'my-window))
- >
- >(defmethod view-key-event-handler ((foo my-window) char)
- > (print char))
- >
- >(setf *true* t)
- >
- >(while *true*
- > ()))
- >
- >(defmethod view-click-event-handler ((foo my-window) position)
- > (declare (ignore position))
- > (while *true*
- > ()))
- >
- >When the function WHILE is called in Listener, the method
- >view-key-event-handler works, that is, I can see characters
- >on Listener. However, when WHILE is called inside the method
- >view-click-event-handler, the method does not work. I want
- >other events to be able to work when a loop function is called
- >inside a method. I am wondering whether I have missed something
- >and there are other ways to do the function.
- >
- >Thanks for your help.
- >
- >jipan@gmuvax2.gmu.edu
-
- As I said in mail to INFO-MCL last week, event processing is locked out
- while processing an event. In MCL 2.0 this is done by binding the
- special variable ccl::*processing-events* to true. In 2.1, this will
- be done differently. Hence, I suggest that you use the following macro
- if you really must allow events while processing an event. You should
- realize that though wrapping the loop inside your event handler with an
- (allowing-events (loop ...)) will allow keyboard input to go to the Listener,
- it won't evaluate any of those expressions until the event handler exits. MCL
- does NOT (yet) have multiple processes.
-
- ------------------------------------------------------------------------
-
- ; allowing-events.lisp
- ;
- ; Macro to allow event processing from within an event handler.
- ; Usually, this is not the right thing to do: use EVAL-ENQUEUE instead.
- ; This code works for MCL 2.0. It will likely break in future versions.
-
- (in-package :ccl)
-
- (export 'allowing-events)
-
- (defmacro allowing-events (&body body)
- `(let ((*processing-events* nil)
- (*interrupt-level* 0))
- ,@body))
-