A bug in ActiveTcl 8.4.5/BWidget 1.7?

From: Scott Gamon (sgamon_at_yahoo.com)
Date: 11/27/03


Date: 26 Nov 2003 19:56:43 -0800

I've encountered a problem, using ActiveTcl 8.4.5 on Windows XP.

After installing ActiveTcl 8.4.5, it appears that BWidget has been
revved to 1.7. Interestingly, the directory is still called
bwidget1.6, but package provides reports 1.7.

Anyhoo, the bug appears when you select an item in a ListBox, then use
the arrow keys to move the selection up or down. The following code
illustrates the bug:

-----------------------------

package require BWidget

proc ListboxCursor {Widget Arrow} {
        switch -- $Arrow {
                up {set Increment -1}
                down {set Increment 1}
        }
        
        set ItemNum [expr {[$Widget selection get] + $Increment}]
        if {$ItemNum < 0} {set ItemNum 0}
        set MaxItems [expr {[llength [$Widget items]] - 1}]
        if {$ItemNum > $MaxItems} {set ItemNum $MaxItems}
        
        $Widget selection set $ItemNum
}

proc FocusOn {Widget args} {
        focus $Widget
}

ListBox .list \
        -yscrollcommand {.vsb set} \
        -width 25 \
        -bg white \
        -selectmode single \
        -takefocus 1
scrollbar .vsb -command {.list yview}

pack .vsb -side right -fill y
pack .list -side left -fill both -expand yes

set i 0

foreach Letter {A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}
{
    .list insert $i "$i" -text [string repeat $Letter 20]
        incr i
}

bind .list <ButtonRelease-1> {FocusOn .list}
.list bindText <ButtonRelease-1> {FocusOn .list}
bind .list <Key-Up> {ListboxCursor .list up}
.list bindText <Key-Up> {ListboxCursor .list up}
bind .list <Key-Down> {ListboxCursor .list down}
.list bindText <Key-Down> {ListboxCursor .list down}

---------------------------

Click on an item. Then use the arrow keys to move the selection up
and down. On my system, the select jumps two places each time you
press an arrow key.

If you change the package require command to:

package require -exact BWidget 1.6

then the problem goes away. Assuming, of course, that you still have
1.6.

Any advice for patching BWidget is greatly appreciated.

Thanks,
Scott


Quantcast