Thanks Felip, but I've actually solved it by writing a bit of Tcl/Tk code and putting it in init-wish. Instead of displaying coordinates on the statusbar I've decided to have them follow the mouse pointer on the canvas itself.
Many thanks for your suggestion though.
Chris
--- On Thu, 1/1/09, Felip Alàez Nadal uu.nix.uu@gmail.com wrote:
From: Felip Alàez Nadal uu.nix.uu@gmail.com Subject: Re: [ltk-user] Displaying mouse pointer coordinates To: chris_melen@yahoo.com, "Talk about Ltk the Lisp Toolkit" ltk-user@common-lisp.net Date: Thursday, 1 January, 2009, 11:13 AM 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@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@common-lisp.net http://common-lisp.net/mailman/listinfo/ltk-user
-- Felip Alàez Nadal