How do I get the position of the mouse?

Does this help?

Canvas item selection by mouse click
There are 2 problems when looking for items at a given position:

On mouse click, you get window coordinates, but you need canvas coordinates for "find".

Canvas find returns only the ID of the item, that's a plain number. You will need to retrieve the parameters of the item by further functions.

Example:

canvas .c1 bind .c1 <Double-1> { onDblClick %x %y } proc onDblClick {x y} { set x [.c1 canvasx $x] ; set y [.c1 canvasy $y] set i [.c1 find closest $x $y] set t [.c1 gettags $i] puts "$i $t" }

In reply to Re: Tcl/Tk mouse events by Anonymous Monk
in thread Tcl/Tk mouse events by Sandy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.