home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / lisp / mcl / 1366 < prev    next >
Encoding:
Internet Message Format  |  1992-09-14  |  2.5 KB

  1. Path: sparky!uunet!sun-barr!ames!data.nas.nasa.gov!taligent!apple!apple!cambridge.apple.com!bill@cambridge.apple.com
  2. From: bill@cambridge.apple.com (Bill St. Clair)
  3. Newsgroups: comp.lang.lisp.mcl
  4. Subject: Re: Multiple events
  5. Message-ID: <9209141614.AA23046@cambridge.apple.com>
  6. Date: 14 Sep 92 17:22:26 GMT
  7. Sender: info-mcl-request@cambridge.apple.com
  8. Lines: 60
  9. Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
  10. Full-Name: Bill St. Clair
  11. Original-To: jipan@gmuvax2.gmu.edu (Jiqian Pan)
  12. Original-Cc: info-mcl
  13.  
  14. >Hi, MCL Experts:
  15. >
  16. >Here are some funny things about other events when a WHILE function
  17. >is called inside a method and in Listener.  Their code is:
  18. >
  19. >(defclass my-window (window) ()) 
  20. >
  21. >(setf foo (make-instance 'my-window))
  22. >
  23. >(defmethod view-key-event-handler ((foo my-window) char)
  24. >           (print char))
  25. >
  26. >(setf *true* t)
  27. >
  28. >(while *true*
  29. >        ()))
  30. >
  31. >(defmethod view-click-event-handler ((foo my-window) position)
  32. >           (declare (ignore position))
  33. >           (while *true*
  34. >                  ()))
  35. >
  36. >When the function WHILE is called in Listener, the method 
  37. >view-key-event-handler works, that is, I can see characters
  38. >on Listener.  However, when WHILE is called inside the method
  39. >view-click-event-handler, the method does not work.  I want 
  40. >other events to be able to work when a loop function is called
  41. >inside a method.  I am wondering whether I have missed something
  42. >and there are other ways to do the function.  
  43. >
  44. >Thanks for your help.
  45. >
  46. >jipan@gmuvax2.gmu.edu
  47.  
  48. As I said in mail to INFO-MCL last week, event processing is locked out
  49. while processing an event. In MCL 2.0 this is done by binding the
  50. special variable ccl::*processing-events* to true. In 2.1, this will
  51. be done differently. Hence, I suggest that you use the following macro
  52. if you really must allow events while processing an event. You should
  53. realize that though wrapping the loop inside your event handler with an
  54. (allowing-events (loop ...)) will allow keyboard input to go to the Listener,
  55. it won't evaluate any of those expressions until the event handler exits. MCL
  56. does NOT (yet) have multiple processes.
  57.  
  58. ------------------------------------------------------------------------
  59.  
  60. ; allowing-events.lisp
  61. ;
  62. ; Macro to allow event processing from within an event handler.
  63. ; Usually, this is not the right thing to do: use EVAL-ENQUEUE instead.
  64. ; This code works for MCL 2.0. It will likely break in future versions.
  65.  
  66. (in-package :ccl)
  67.  
  68. (export 'allowing-events)
  69.  
  70. (defmacro allowing-events (&body body)
  71.   `(let ((*processing-events* nil)
  72.          (*interrupt-level* 0))
  73.      ,@body))
  74.