tkevent

This is a sample implementation of tkevent, as specified in an upcoming TIP.

proc tkevent_cmd {cmd ev} {
    {*}$cmd [dict filter $ev script {k v} {expr {$v != "??"}} ]
}

set tkevent_dict {
        -serial %#       -above %a        -button %b
        -count %c        -detail %d       -focus %f
        -height %h       -windowid %i     -keycode %k  
        -mode %m         -override %o
        -place %p        -state %s        -time %t
        -width %w        -x %x            -y %y
        -character %A    -borderwidth  %B -delta %D
        -sendevent %E    -keysym %K       -keysym_num %N
        -property %P     -root %R         -subwindow %S
        -type %T         -window %W       -rootx %X
        -rooty %Y}

proc tkevent {wid evt cmd} {
    bind $wid $evt [list tkevent_cmd $cmd [concat event $evt $::tkevent_dict]]
}

Example:

label .l -text "Press me"
pack .l
tkevent .l <1> callback
proc callback {e} {
    puts "event x is is [dict get $e -x]"
}