home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / lisp / mcl / 1919 < prev    next >
Encoding:
Text File  |  1992-12-31  |  3.5 KB  |  114 lines

  1. Path: sparky!uunet!olivea!apple!cambridge.apple.com!jbk@world.std.com
  2. From: jbk@world.std.com (Jeffrey B Kane)
  3. Newsgroups: comp.lang.lisp.mcl
  4. Subject: Re: Views and keystrokes
  5. Message-ID: <199212311517.AA21709@world.std.com>
  6. Date: 31 Dec 92 15:17:09 GMT
  7. Sender: info-mcl-request@cambridge.apple.com
  8. Lines: 103
  9. Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
  10.  
  11.  
  12. > The only problem is that you need to define a dialog-item-enabled-p
  13. > method for your key handler class
  14.  
  15. Bill,
  16.   Thanks for the clue.  I saw the error message complaining that no 
  17. "dialog-item-enabled-p" was defined for my view class, but I assumed
  18. that I was on the wrong track, since I wasn't trying to define a 
  19. dialog item.  One last question.  After implementing the patch I get
  20. most key strokes, but I can only get access to a #\Tab key if I hold
  21. down the shift-tab combination.  Is this because the window now thinks
  22. that the view is a dialog item?  Below is the code that prints out
  23. any keys that it gets:
  24.  
  25. ;;
  26. ;; A simple color window
  27. ;;
  28. (defclass special-window (window)  ; should NOT inherit from key-handler-mixin
  29.   (default-initarg
  30.     :color-p t))
  31.  
  32. ;;;;;;;;;;;;;;;;;;;;;;;;;;
  33. ;;
  34. ;; A simple view
  35. ;;
  36. (defclass special-view (key-handler-mixin view)
  37.   nil)
  38.  
  39. ;;;;;;;;;;;;;;;;;;;;;;;;;;
  40. ;;
  41. ;; This is necessary for key-handler-mixin.
  42. ;; patch 2 (which has not yet been released) will make this unnecessary.
  43. (defmethod dialog-item-enabled-p ((item special-view))
  44.   t)
  45.  
  46. ;;;;;;;;;;;;;;;;;;;;;;;;;;
  47. ;;
  48. ;; ** define a method to let us know what key is being pressed
  49. ;;
  50. (defmethod view-key-event-handler ((self special-view) char)
  51.   "just beep if the user types a key"
  52.   (format t "~S" char)
  53.   (case char
  54.     (#\ForwardArrow (set-view-position self (add-points (view-position self) 
  55.                                                         #@(10 0))))
  56.     (#\BackArrow (set-view-position self (subtract-points (view-position self) 
  57.                                                           #@(10 0))))
  58.     (#\UpArrow (set-view-position self (subtract-points (view-position self) 
  59.                                                         #@(0 10))))
  60.     (#\DownArrow (set-view-position self (add-points (view-position self) 
  61.                                                      #@(0 10))))
  62.  
  63.     (otherwise char))  ; ?prints char in the listener, even though we haven't called (call-next-method)?
  64.   (values))
  65. ;;;;;;;;;;;;;;;;;;;;;;;;;;
  66. ;;
  67. ;; just to let us know our view exists
  68. ;;
  69. (require "QUICKDRAW")
  70.  
  71. (defmethod view-draw-contents ((self special-view))
  72.   ;frame and color the rect
  73.   (rlet ((r :rect
  74.             :topleft #@(0 0)
  75.             :bottomright (view-size self)))
  76.     (with-fore-color *yellow-color*
  77.       (paint-rect self r))
  78.     (with-pen-saved 
  79.       (set-pen-size self 2 2)
  80.       (frame-rect self r)
  81.       (move-to self (rref r :rect.topleft))
  82.       (line-to self (rref r :rect.bottomright))
  83.       (move-to self 0 (rref r :rect.right))
  84.       (line-to self (rref r :rect.bottom) 0))))
  85.  
  86.  
  87. ;;;;;;;;;;;;;;;;;;;;;;;;;;
  88. ;;
  89. ;; create the window and it's contained view
  90. ;;
  91. (defvar temp-wind nil)
  92. (defvar temp-view nil)
  93. (setf temp-wind
  94.       (make-instance 'special-window
  95.         :view-subviews
  96.         (list (setf temp-view
  97.                     (make-instance 'special-view
  98.                       :view-position #@(40 40)
  99.                       :view-size #@(150 150))))))
  100.  
  101.     Jeffrey
  102.  
  103.  
  104. ======================================
  105. Jeffrey Kane, MD
  106. Kane Biomedical Systems
  107. Boston, MA
  108.  
  109. Internet    jbk@world.std.com
  110. Compuserve  74206,640
  111. AppleLink   D0738
  112.  
  113. [Don't take life too seriously... it's not like anyone gets out of it alive.]
  114.