#1872 MacOS X : mouse co-ordinates reported offset from pointer

obsolete: 8.4.9

This bug is rather more troublesome than it would
appear at first sight, given the utterly contrived
nature of the example presented here.

We find that mouse events (click, drag, etc.) are
frequently reported as having occurred at a position
offset from the pointer. This affects
application-specific bindings, such as those we create
for a user to draw on a canvas, and also internal Tk
bindings, such as those needed to trigger a button
press. This latter artefact can give the interface the
appearance of being hung or frozen.

The workaround is to move the window (even very
slightly) by dragging the title bar.

As I say, it occurs quite frequently in practice, but
it hasn't been all that easy to find a simple sequence
of steps that reliably reproduces the problem. Now
here goes...

1. Create a Tcl/Tk script "offset.tcl" in your
working directory (attached)
2. Start "wish" from the Terminal command prompt
in your working directory
3. Enter the following three commands at the %
prompt, and WITHOUT touching the "Wish Shell"
source offset.tcl
toplevel .t
destroy .t
4. Click on the title bar of "Wish Shell" to
bring it to the front
5. Click in the canvas (i.e. anywhere in the
Wish Shell window)

A circle will be drawn on the canvas, but it will be
displaced from the click by a margin of very roughly
50-100 pixels below and to the right. Repeat for as
long as you like :-) Move the window, and click again.
Circles will now be drawn at the mouse pointer
location. You can return focus to the Terminal window
and repeat the creation and destruction of the dummy
top-level in order to re-create the problem. You must
give focus to the Wish Shell window by clicking on its
title bar. If you click anywhere else in the window,
the problem does not arise.

The contents of offset.tcl define the canvas and its
binding :

---Start of offset.tcl---
proc drawCircle {c x y} {
set x1 [expr $x-2]
set y1 [expr $y-2]
set x2 [expr $x+2]
set y2 [expr $y+2]
$c create oval $x1 $y1 $x2 $y2

canvas .c -height 400 -width 400
pack .c
bind .c <Button-1> "drawCircle .c %x %y"
--- End of offset.tcl ---


  • Alastair Davies

    Alastair Davies - 2005-03-09

    Procedures defining canvas and binding

  • Jim Ingham

    Jim Ingham - 2005-03-10

    Logged In: YES

    The code that was handling mouse clicks in the drag region of the window
    was assuming that the window clicked on was already the current
    GrafPort. When the window was in the background, it wasn't yet the
    current GrafPort, so it would set the root coordinates of the window

    I attached a patch that fixes the problems. I will be interested to see
    whether this also fixes your less artificial problems...

  • Jim Ingham

    Jim Ingham - 2005-03-10
    • assigned_to: das --> wolfsuit
    • status: open --> open-fixed
  • Jim Ingham

    Jim Ingham - 2005-03-10

    Logged In: YES

    I also checked this into TOT & core-8-4-branch

  • Jim Ingham

    Jim Ingham - 2005-04-18
    • status: open-fixed --> closed-fixed

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks