1

When getting events from (read-event) it's possible to access only mouse events using (mouse-movement-p event).

Inspecting the events I've found I can get the Y pixel location using (cdr (nth 2 (nth 1 event)) however this seems overly cryptic.

What is a good way to access data in mouse motion events?

3

There is a list of functions with the posn prefix to extract that information and more from mouse events. One caveat is that many of them require a start/end event:

(let ((e (read-event)))
  (when (mouse-event-p e)
    (let ((x-y (posn-x-y (event-start e))))
      (message "Mouse event at: %d|%d" (car x-y) (cdr x-y)))))
  • How to access pixel coordinates? – ideasman42 Jul 14 at 11:59
  • Wasamasa answered exactly the question in your comment, no? C-h f posn-x-y. – Drew Jul 14 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.