[ltk-user] Displaying mouse pointer coordinates

Felip Alàez Nadal uu.nix.uu at gmail.com
Thu Jan 1 11:13:05 UTC 2009


Maybe It would be better if you insert a label inside your canvas and you
only change the text on It. It would be really faster than destrolling and
creating the canvas everytime. You can also write text on the canvas, and
change It when you need.

Felip.

2008/12/29 christopher melen <chris_melen at yahoo.com>

> Hi,
>
> I'm trying to display the coordinates of the mouse pointer. My app consists
> of a canvas and a 'statusbar', both of which are contained in a toplevel.
> The statusbar (which is just a frame containing another canvas) contains
> text displaying the current position of the mouse pointer, and this is
> updated as the pointer moves. What I'm doing is deleting and then recreating
> the text with the new coordinates, but this results in an unpleasant
> 'flashing' effect (not so bad on WinXP but terrible on OS X). Is there a
> more efficient way of doing this? I know there are Tk-based apps which
> achieve this effect (such as Wavesurfer), so it must be do-able. This is the
> relevant event handler code -
>
> (bind *canvas* "<Motion>"
>      (lambda (evt)
>            (let* ((x (event-x evt))
>                   (y (event-y evt)))
>                  (setf *x-coord* x *y-coord* y)
>                  (itemdelete *statusbar* *coord-display*)
>                  (make-coord-display))))
>
> *canvas* is the main canvas, and *statusbar* the statusbar. *x-coord* and
> *y-coord* are bound to the current pointer coordinates, which are used by
> the statusbar's text item (bound to *coord-display*). The function
> MAKE-COORD-DISPLAY then recreates the text on the statusbar immediately
> after it has been deleted (hence the flashing).
>
> Many thanks in advance for any suggestions.
>
> Chris
>
> P.S: Also a strange thing happens if I use the above code for a canvas
> owned by a paned-window - the sash disappears. Odd...
>
>
>
>
> _______________________________________________
> ltk-user site list
> ltk-user at common-lisp.net
> http://common-lisp.net/mailman/listinfo/ltk-user
>



-- 
Felip Alàez Nadal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ltk-user/attachments/20090101/7f944cf7/attachment.html>


More information about the ltk-user mailing list