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

Traps and Events



I'm trying to do something which I thought would be very simple: write a
function that prints the local coordinates of the mouse position in the
window in which the mouse is clicked. If clicked on the desktop, or in a
scrollbar or titlebar, nothing happens, apart from normal event processing.

I know about *eventhook*, which I'm using to toggle my function, and I know
about *current-event* and I'm using #_findwindow to determine in which
window the mouse was clicked, and in which part of that window. The problem
is that #_findwindow returns a window pointer, and view-mouse-position
takes a window as an argument and I'm not quite sure how to handle this and
do it properly!

This is what I have (which is obviously wrong):

(defun mouse-coords (&aux thePart)
  (if (equal (rref *current-event* :EventRecord.what)
             #$mouseDown)
    (rlet ((whichWindow :integer))
      (setq thePart (#_findwindow (rref *current-event* :EventRecord.where)
                                 whichWindow))
      (if (equal thePart #$inContent)
        (format t "Mouse at ~A~%"
                (point-string (view-mouse-position whichWindow)))))))

Any and all help gratefully appreciated.
Charlene