RosettaCodeData/Task/Mouse-position/Tcl/mouse-position.tcl
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

6 lines
323 B
Tcl

package require Tk 8.5
set curWindow [lindex [wm stackorder .] end]
# Everything below will work with anything from Tk 8.0 onwards
set x [expr {[winfo pointerx .] - [winfo rootx $curWindow]}]
set y [expr {[winfo pointery .] - [winfo rooty $curWindow]}]
tk_messageBox -message "the mouse is at ($x,$y) in window $curWindow"