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

Re: Event troubles?

   Date: Mon, 10 Sep 90 00:30:36 PDT
   From: nakamura@SOE.Berkeley.Edu (Mark Nakamura)
   Message-Id: <9009100730.AA17870@dewey.soe.berkeley.edu>
   To: info-macl@cambridge.apple.com
   Subject: Event troubles?
   Am I losing my mind, or what is going on here?
   I am having significant troubles getting the MACL window event handlers to
   work.  What am I doing wrong?
   I boot 1.3.2.
   ;; I create a window.
   (oneof *window*)
   ;; I try to modify the window-select-event-handler:
   (defobfun (window-select-event-handler *window*) ()
   ;; Then nothing happens.  This completely disables my ability to select
   ;; windows with the mouse.  So I think, oh shit, better redefine it:
   (defobfun (window-select-event-handler *window*) ()
   ;; And still window selection with the mouse fails to work.  The only way
   ;; that I can get it to work again is by loading the traps and doing:
   (defobfun (window-select-event-handler *window*) ()
     (_SelectWindow :long <ptr to window>))
   ;; So, I try the same thing with the window-key-up-event-handler.
   (defobfun (window-key-up-event-handler *window*) ()
   ;; NOTHING HAPPENS.  No beep when keys come up in any windows.
   What am I doing wrong, or what is wrong with 1.3.2?  I _need_ to have
   this functionality.

This happens to a lot of people when they first use object-lisp.  To clarify
what's going on, I present a little example.

Suppose somewhere in the depths of your Lisp was the following code:

(defun foo (x)
  (do-something-really-important x))

Then you redefine foo as follows:

(defun foo (x)
  (format t "~&Hi Mom!  FOO was just called with ~s.~%" x)

Would you be surprised to see:

? (foo 1)
Hi Mom!  FOO was just called with 1.

Instead of DO-SOMETHING-REALLY-IMPORTANT being called to do what it
needs to do?

This is exactly what's happenning.  MACL has a
WINDOW-SELECT-EVENT-HANDLER function for *WINDOW* that takes care of
calling _WindowSelect (amongst other things) when you click on a
window.  Your code is redefining it.

What you need to do is create your own class of window and define
object functions on it:

(defobject *my-window* *window*)

(defobfun (window-select-event-handler *my-window*) ()

Then you can say:

(oneof *my-window*)

And the window will beep whenever you select it.