Menu

#101 entryfield paste behavior busted

4.0.0
open
EntryField (4)
5
2013-01-17
2006-09-21
No

Wow, how can a bug like this go unnoticed for so long?

The short version is, when pasting into a entryfield,
length validation will be performed based on the
contents and configuration of the most recently created
entryfield rather than on the entryfield with the focus.

in entryfield.tcl is this happy bit of code:

if {($itk_option(-pasting))} {
bind pastetag <ButtonRelease-2> [itcl::code
$this _checkLength]
bind pastetag <Control-v> [itcl::code $this
_checkLength]
bind pastetag <Insert> [itcl::code $this
_checkLength]
bind pastetag <KeyPress> {}
} else {
bind pastetag <ButtonRelease-2> {break}
bind pastetag <Control-v> {break}
bind pastetag <Insert> {break}
bind pastetag <KeyPress> {
# Disable function keys > F9.
if {[regexp {^F[1,2][0-9]+$} "%K"]} {
break
}
}
}

Notice that it redefines the bindings to "pastetag"
each time the code runs even though "pastetag" has a
global effect. The result is that the _checkLength will
always compare the length of the data to be pasted
against the contents of the last entryfield to have
been created.

The solution is to either rip out all the attempts at
being clever about paste, or create a unique paste
bindtag for every entryfield object.

Discussion


Log in to post a comment.