[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

basic view-key-event-handler confusion

Please help.

There is something *very basic* that I don't understand about 
view-key-event-handlers, despite having read and re-read
the docs and sample code a hundred times.  Here is a simple 
example that fails to handle key events -- all keystrokes go 
to the listener:

(defclass simple-key-handling-view (dialog-item)

;;; When you get a keystroke, draw that character.

(defmethod view-key-event-handler ((item simple-key-handling-view)
  "Just print the character in the view."
  (when (integerp char) (setq char (code-char char)))  ; (why?)
  (move-to item 20 20)
  (format item "~c" char))

(setq *w* (make-instance 'window))
(setq *v* (make-instance 'simple-key-handling-view
            :view-position #@(4 4)
            :view-size #@(200 200)))

(add-subviews *w* *v*)

;;; (key-handler-p *v*)  --> NIL

Please don't tell me to use an instance of some text dialog
item; I want to do something very special with the keystrokes,
and anyway there must be a simpler way...

Many, many thanks for your kind attention.

-Tom McDougal          mcdougal@cs.uchicago.edu         (312) 702-0024
Dept. of Computer Science, University of Chicago