The proc
# creating the entry widget
pack [entry .e]
# focusing the entry widget
focus -force .e
# binding to key press
bind .e <KeyPress> { overwrite %A }
# overwriting proc
proc overwrite {ch} \
{
if {![string is control $ch]} \
{ # for a standard char
# updating ::n if needed
set i [.e index insert]
if {$i != $::n} { set ::n $i }
# overwriting the char
.e delete $::n
.e insert $::n $ch
# selecting the next char
prepare
# avoiding the Entry class proc
return -code break
}
}
# next selecting proc
proc prepare {} \
{
incr ::n
.e icursor $::n
.e selection from $::n
.e selection to [expr {$::n + 1}]
}The test
# initial string .e insert 0 "the initial string" # selecting the first char set ::n -1 prepareNow, type ahead!
Category Example | Category Widget

