Posted to tcl by mjanssen at Wed Jan 23 13:30:46 GMT 2008view raw

  1. text .t
  2. pack .t
  3. bind .t <Control-V> {
  4. set uc_keys {}
  5. bindtags %W [list Unicode {*}[bindtags %W]]
  6. }
  7.  
  8. variable uc_keys
  9. proc handle_uc_key {widget key} {
  10. puts handle_uc
  11. global uc_keys
  12. switch -nocase -regexp -- $key {
  13. {[0-9A-F]} {
  14. append uc_keys $key
  15. if {[string length $uc_keys] == 4} {
  16. $widget insert insert [subst \\u$uc_keys]
  17. bindtags $widget [lrange [bindtags $widget] 1 end]
  18. }
  19. return -code break
  20. }
  21. default {
  22. $widget insert insert $uc_keys
  23. bindtags $widget [lrange [bindtags $widget] 1 end]
  24. }
  25. }
  26. }
  27.  
  28.  
  29. bind Unicode <Key> {handle_uc_key %W %A}