Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Tcl/Tk mouse events

by Anonymous Monk
on Mar 04, 2016 at 05:50 UTC ( [id://1156792]=note: print w/replies, xml ) Need Help??


in reply to Tcl/Tk mouse events

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" }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1156792]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-26 02:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found