home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / lisp / mcl / 1614 < prev    next >
Encoding:
Text File  |  1992-11-18  |  1.8 KB  |  57 lines

  1. Newsgroups: comp.lang.lisp.mcl
  2. Path: sparky!uunet!paladin.american.edu!darwin.sura.net!spool.mu.edu!agate!boulder!cambridge.apple.com!apple!ames!ncar!uchinews!tango.uchicago.edu!mcdougal
  3. From: mcdougal@cs.uchicago.edu (Tom McDougal)
  4. Subject: basic view-key-event-handler confusion
  5. Message-ID: <722101331.26830@news.Colorado.EDU>
  6. Lines: 41
  7. Sender: news
  8. Organization: Univ. of Chicago Computer Science
  9. Distribution: co
  10. Date: 17 Nov 92 21:52:12 GMT
  11. Approved: news
  12. X-Note1: mail msgid was <1992Nov17.215212.7762@midway.uchicago.edu>
  13. X-Note2: message-id generated by recnews
  14. Lines: 41
  15.  
  16. Please help.
  17.  
  18. There is something *very basic* that I don't understand about 
  19. view-key-event-handlers, despite having read and re-read
  20. the docs and sample code a hundred times.  Here is a simple 
  21. example that fails to handle key events -- all keystrokes go 
  22. to the listener:
  23.  
  24. (defclass simple-key-handling-view (dialog-item)
  25.   ()
  26.   )
  27.  
  28. ;;; When you get a keystroke, draw that character.
  29. ;;;  ***BUT NOTHING HAPPENS
  30.  
  31. (defmethod view-key-event-handler ((item simple-key-handling-view)
  32. char)
  33.   "Just print the character in the view."
  34.   (when (integerp char) (setq char (code-char char)))  ; (why?)
  35.   (move-to item 20 20)
  36.   (format item "~c" char))
  37.  
  38. (setq *w* (make-instance 'window))
  39. (setq *v* (make-instance 'simple-key-handling-view
  40.             :view-position #@(4 4)
  41.             :view-size #@(200 200)))
  42.  
  43. (add-subviews *w* *v*)
  44.  
  45. ;;; (key-handler-p *v*)  --> NIL
  46.  
  47.  
  48. Please don't tell me to use an instance of some text dialog
  49. item; I want to do something very special with the keystrokes,
  50. and anyway there must be a simpler way...
  51.  
  52. Many, many thanks for your kind attention.
  53.  
  54. ----------------------------------------------------------------------
  55. -Tom McDougal          mcdougal@cs.uchicago.edu         (312) 702-0024
  56. Dept. of Computer Science, University of Chicago
  57.