Tk Source Code

Artifact [ba6d7584]
Login

Artifact ba6d75843096e8536045c142c0c25d013d3b0d296b885944ad518660b8843252:

Attachment "exercise.tcl" to ticket [b358779b] added by erikleunissen 2020-09-28 09:45:42.
#! /usr/bin/tclsh

package require Tk
wm deiconify .
pack propagate . 0

# Create a toplevel with simple menubar. The dummy menu button is only needed
# to make the height of the menubar > 0, not for the exercising of the issue.
menu .m -type menubar -bg yellow -bd 2
. configure -menu .m
.m add command -label Dummy -command {}

# an arbitrary widget to compare with
pack [frame .f -width 80 -height 80 -bg lightblue] -side bottom -anchor sw

# create a marker widget
label .marker -bg lightgreen -textvariable windowDetected

# let the mouse pointer detect windows, and place
# a marker at its center.
proc handleEvent {W}  {
	if {($W eq "") || ($W eq ".marker")} {
		return
	}
	place .marker -in $W -relx 0.5 -rely 0.5
	set ::windowDetected $W
}
bind all <Enter> [list handleEvent %W]
bind all <Leave> {handleEvent [winfo parent %W]}