Version 0 of A Quick Demo of Enter and Leave Event Bindings

Updated 2005-08-12 16:44:39

proc makeRoom {widget name polyCoords} {

     set id [$widget create poly $polyCoords -fill green -outline black]
     $widget bind $id <Enter> [list enterRoom $widget $id $name]
     $widget bind $id <Leave> [list leaveRoom $widget $id]
     $widget scale $id 0 0 20 20 }
 proc enterRoom {widget id name} {
     $widget itemconfigure Title -text $name
     $widget itemconfigure $id -fill yellow -outline red }
 proc leaveRoom {widget id} {
     $widget itemconfigure Title -text ""
     $widget itemconfigure $id -fill green -outline black }
 proc start {widget} {
     destroy $widget ; pack [canvas $widget]
     makeRoom $widget "Bedroom" {1 1 4 1 4 3 1 3}
     makeRoom $widget "Kitchen" {5 1 9 1 9 3 5 3}
     makeRoom $widget "Hallway" {4 1 5 1 5 3 9 3 9 4 1 4 1 3 4 3}
     makeRoom $widget "Recroom" {9 4 9 9 1 7 1 4}
     $widget create text 40 10 -tag Title }
 start .c