all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Masatake YAMATO <jet@gyve.org>
Cc: emacs-devel@gnu.org
Subject: Re: `posn-at-point' and `posn-at-x-y' not in manual
Date: Sat, 05 Jun 2004 01:53:18 +0900 (JST)	[thread overview]
Message-ID: <20040605.015318.205310889.jet@gyve.org> (raw)
In-Reply-To: <6581542.1086359828010.JavaMail.www@wwinf0603>

> >>Of course!  Thanks!
> >>As an example, here is an implementation of a `set-mouse-at-point'
> >>function that seems to work very well :-)
> > 
> > 
> > How about tooltip?
> > Doctor, please show a sample. People wish your epiphany:-)
> > 
> 
> Here it is:

Thank you, sir. 
However, I'd like not to move the mouse cursor if possible.
I've implemented `point-pixel-position' based on your code.
Maybe this code is applicable to popup menu.

(defun point-pixel-position ()
  "Same as `mouse-pixel-position' but for point."
  (let* ((pos (posn-at-point))
         (x-y (posn-x-y pos))
         (wnd (posn-window pos))
         (frm (window-frame wnd))
         (edg (window-pixel-edges wnd)))
    (cons
     frm
     (cons (+ (car x-y) (car  edg) (frame-char-width frm))
	   (+ (cdr x-y) (cadr edg) (/ (frame-char-height frm) 2))))))

(defun tooltip-show-at-point (text)
  "Display a tooltip with TEXT near cursor without moving mouse cursor."
  (let* ((oP (mouse-pixel-position))
	 (nP (point-pixel-position))
         (tooltip-x-offset tooltip-x-offset)
         (tooltip-y-offset tooltip-y-offset))
    ;; The current mouse position is out of range.
    ;; Do dirty thing here.
    (if (or (null (cadr oP))
	    (null (cddr oP)))
	(set-mouse-pixel-position (nth 0 nP)
				  (nth 1 nP) (nthcdr 2 nP))
      (setq tooltip-x-offset (+ (if tooltip-x-offset tooltip-x-offset 5)
			      (- (cadr nP) (cadr oP)))
	    tooltip-y-offset (+ (if tooltip-y-offset tooltip-y-offset -10)
				(- (cddr nP)(cddr oP)))))
    (tooltip-show text)
    ))

  reply	other threads:[~2004-06-04 16:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-04 14:37 `posn-at-point' and `posn-at-x-y' not in manual David PONCE
2004-06-04 16:53 ` Masatake YAMATO [this message]
2004-06-04 17:11   ` Masatake YAMATO
  -- strict thread matches above, loose matches on Subject: below --
2004-06-07 10:14 David PONCE
2004-06-04 12:15 David PONCE
2004-06-04 12:23 ` Masatake YAMATO
2004-06-07 10:47 ` Kim F. Storm
2004-06-04 11:56 David PONCE
2004-06-04 12:10 ` David Kastrup
2004-06-05 13:49 ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040605.015318.205310889.jet@gyve.org \
    --to=jet@gyve.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.