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

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 {}]
    }
}

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 {}] } }