I wrote this procedure to do the job:
# Remove first Cmd from bind pattern.
# @return true if removed
proc gui::guiBindRemove {Win Pattern CmdIn} {
set CmdCur [bind $Win $Pattern]
while {-1 != [set Pos [string first $CmdIn $CmdCur]]} {
# >> Check if found string starts at the beginning of after a
new-line
if { $Pos == 0 || [string index $CmdCur $Pos-1] eq "\n" } {
# >> Check if found string ends at end or before a new-line
set PosEnd [expr {$Pos + [string length $CmdIn]}]
if { $PosEnd == [string length $CmdCur]
|| [string index $CmdCur $PosEnd] eq "\n"
} {
# Binding found
if {$Pos != 0} {
set CmdNew [string range $CmdCur 0 $Pos-2]
} else {
set CmdNew ""
}
if {$PosEnd!= [string length $CmdCur]} {
if {$CmdNew ne ""} {
append CmdNew \n
}
append CmdNew [string range $CmdCur $PosEnd+1 end]
}
bind $Win $Pattern $CmdNew
return 1
}
}
}
return 0
}
Is this wise ?
Should it go to the wiki ?
Or in a TIP for bind Win Pattern -CmdIn ?
Thanks,
Harald