help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: can someone help me with the image elisp API


From: Andy Moreton
Subject: Re: can someone help me with the image elisp API
Date: Tue, 08 Dec 2015 09:30:41 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (windows-nt)

On Mon 07 Dec 2015, Jim Newton wrote:

> I've opened an image (a .png) file in an emacs buffer.
> I'd like to be able to click in the image with the RMB (or any good mouse 
> event),
> and somehow relate the point the user clicked to the 
> coordinates in the image.
>
> For example, this elisp function gets the x-y position.  Suppose it is (609 . 
> 41)
> I want to know if that is in the box within the image coordinates
>  (( 447.32 199.28) ( 449.7426 199.9871))
>
> I need of course to consider that the user might have scrolled or panned or 
> zoomed
> within the image before calling the class-graph-from-click function.
>
> (defun class-graph-from-click (event)
>   (interactive "e")
>   (let ((position (event-start event)))
>     (posn-x-y position) ;; this is the x-y where the mouse was clicked-down
>     (message "xy=%s" (posn-x-y position))))

Have a look at the manual at (info "(elisp) Accessing Mouse") which
shows the utility functions provided for handling mouse position data.
It looks like 'posn-image and 'posn-object-x-y position are what you
need.

    AndyM




reply via email to

[Prev in Thread] Current Thread [Next in Thread]