Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1320 listbox updates unnecessary when selection doersnot change,

closed-accepted
bwidget (187)
5
2012-04-12
2012-04-12
No

Here is a tiny enhancement for the listbox (from V1.29.2.6 in bwidget 1.9.5) widget to avoid redrawing when selection does not change. This happens frequently when a listbox with hottrack enabled displays image and text and the cursor is moved in the area right to image and text where only the background is displayed. I also detected that the listbox sometimes jumps between two entries when the cursor is positioned just between the entries for this case, at least under Linux with Tk8.5.9

proc ListBox::selection { path cmd args } {
variable $path
upvar 0 $path data

set oldsel $data(selitems);
switch -- $cmd {
set {
set data(selitems) {}
foreach item $args {
if { [lsearch -exact $data(selitems) $item] == -1 } {
if { [lsearch -exact $data(items) $item] != -1 } {
lappend data(selitems) $item
}
}
}
}
add {
foreach item $args {
if { [lsearch -exact $data(selitems) $item] == -1 } {
if { [lsearch -exact $data(items) $item] != -1 } {
lappend data(selitems) $item
}
}
}
}
remove {
foreach item $args {
if { [set idx [lsearch -exact $data(selitems) $item]] != -1 } {
set data(selitems) [lreplace $data(selitems) $idx $idx]
}
}
}
clear {
set data(selitems) {}
}
get {
return $data(selitems)
}
includes {
return [expr {[lsearch -exact $data(selitems) $args] != -1}]
}
default {
return
}
}
if {[string compare $oldsel $data(selitems)]} {
_redraw_idle $path 1
}
return;
}

Discussion

  • Patch looks ok.
    Would be helpful if a demonstation script would be provided.

    Committed to csv.

    Thank you, Wolfgang !
    Harald

     
    • status: open --> closed-accepted