Posted to tcl by evilotto at Wed Apr 13 02:01:56 GMT 2011view raw

  1. proc bindx_cmd {cmd ev} {
  2. {*}$cmd [dict filter $ev script {k v} {expr {$v != "??"}} ]
  3. }
  4.  
  5. proc bindx {wid evt cmd} {
  6. bind $wid $evt [list bindx_cmd $cmd {
  7. serial %#
  8. above %a
  9. button %b
  10. count %c
  11. detail %d
  12. focus %f
  13. height %h
  14. window %i
  15. keycode %k
  16. mode %m
  17. override_redirect %o
  18. place %p
  19. state %s
  20. time %t
  21. width %w
  22. x %x
  23. y %x
  24. character %A
  25. border_width %B
  26. delta %D
  27. send_event %E
  28. keysym %K
  29. keysym_num %N
  30. property %P
  31. root %R
  32. subwindow %S
  33. type %T
  34. window %W
  35. xroot %X
  36. yroot %Y}]
  37. }
  38.  
  39. proc a_cmd {clientdata evt} {
  40. puts "evt $clientdata: $evt"
  41. }
  42.  
  43. label .a -text hello
  44. bindx .a <KeyRelease> {a_cmd one}
  45. bindx .a <1> {a_cmd button}
  46. bindx .a <Configure> {a_cmd conf}
  47.  
  48. pack .a -expand t -fill both
  49. focus .a
  50.