Posted to tcl by emiliano at Tue Dec 17 16:00:32 GMT 2019view raw

  1. namespace eval ::roText {
  2. proc roText {w args} {
  3. text $w {*}$args
  4. rename $w ::roText::$w
  5. proc $w {cmd args} [format {
  6. set w %s
  7. if {$cmd ni "insert delete"} {
  8. ::roText::$w $cmd {*}$args
  9. }
  10. } $w]
  11. bind $w <Destroy> [list rename $w {}]
  12. }
  13. }
  14.  

Comments

Posted by emiliano at Wed Dec 18 13:55:45 GMT 2019 [text] [code]

There's an subtle error; the proc needs to be called ::$w, not $w. namespace eval ::roText { proc roText {w args} { text $w {*}$args rename $w ::roText::$w proc ::$w {cmd args} [format { set w %s if {$cmd ni "insert delete"} { ::roText::$w $cmd {*}$args } } $w] bind $w <Destroy> [list rename $w {}] } }