Skip to content

Commit 31bac40

Browse files
committed
* listbox.tcl(ListBox::bindText and ListBox::bindImage)
Method bindText and bindImage overwrote internal selection bindings [Bug 3000293] reported by Robert Karen.
1 parent b5c219e commit 31bac40

File tree

2 files changed

+47
-29
lines changed

2 files changed

+47
-29
lines changed

ChangeLog

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# ------------------------------------------------------------------------------
22
# ChangeLog
33
# This file is part of Unifix BWidget Toolkit
4-
# $Id: ChangeLog,v 1.216 2010/05/12 08:24:53 oehhar Exp $
4+
# $Id: ChangeLog,v 1.217 2010/05/12 08:28:56 oehhar Exp $
55
# ------------------------------------------------------------------------------
66

7+
2010-05-12 Harald Oehlmann < [email protected]>
8+
9+
* listbox.tcl(ListBox::bindText and ListBox::bindImage)
10+
Method bindText and bindImage overwrote internal selection
11+
bindings [Bug 3000293] reported by Robert Karen.
12+
713
2010-05-11 Harald Oehlmann < [email protected]>
814

915
* listbox.tcl(ListBox::see) Method see shifts image out of

listbox.tcl

+40-28
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ----------------------------------------------------------------------------
22
# listbox.tcl
33
# This file is part of Unifix BWidget Toolkit
4-
# $Id: listbox.tcl,v 1.32 2010/05/12 08:24:53 oehhar Exp $
4+
# $Id: listbox.tcl,v 1.33 2010/05/12 08:28:56 oehhar Exp $
55
# ----------------------------------------------------------------------------
66
# Index of commands:
77
# - ListBox::create
@@ -200,37 +200,37 @@ proc ListBox::_configureSelectmode { path selectmode {previous none} } {
200200
# clear current binding
201201
switch -exact -- $previous {
202202
single {
203-
$path bindText <Button-1> ""
204-
$path bindImage <Button-1> ""
203+
$path _bindText <Button-1> ""
204+
$path _bindImage <Button-1> ""
205205
}
206206
multiple {
207-
$path bindText <ButtonRelease-1> ""
208-
$path bindText <Shift-ButtonRelease-1> ""
209-
$path bindText <Control-ButtonRelease-1> ""
207+
$path _bindText <ButtonRelease-1> ""
208+
$path _bindText <Shift-ButtonRelease-1> ""
209+
$path _bindText <Control-ButtonRelease-1> ""
210210

211-
$path bindImage <ButtonRelease-1> ""
212-
$path bindImage <Shift-ButtonRelease-1> ""
213-
$path bindImage <Control-ButtonRelease-1> ""
211+
$path _bindImage <ButtonRelease-1> ""
212+
$path _bindImage <Shift-ButtonRelease-1> ""
213+
$path _bindImage <Control-ButtonRelease-1> ""
214214
}
215215
}
216216
# set new bindings
217217
switch -exact -- $selectmode {
218218
single {
219-
$path bindText <Button-1> [list ListBox::_mouse_select $path set]
220-
$path bindImage <Button-1> [list ListBox::_mouse_select $path set]
219+
$path _bindText <Button-1> [list ListBox::_mouse_select $path set]
220+
$path _bindImage <Button-1> [list ListBox::_mouse_select $path set]
221221
if {1 < [llength [ListBox::selection $path get]]} {
222222
ListBox::selection $path clear
223223
}
224224
}
225225
multiple {
226226
set cmd ListBox::_multiple_select
227-
$path bindText <ButtonRelease-1> [list $cmd $path n %x %y]
228-
$path bindText <Shift-ButtonRelease-1> [list $cmd $path s %x %y]
229-
$path bindText <Control-ButtonRelease-1> [list $cmd $path c %x %y]
227+
$path _bindText <ButtonRelease-1> [list $cmd $path n %x %y]
228+
$path _bindText <Shift-ButtonRelease-1> [list $cmd $path s %x %y]
229+
$path _bindText <Control-ButtonRelease-1> [list $cmd $path c %x %y]
230230

231-
$path bindImage <ButtonRelease-1> [list $cmd $path n %x %y]
232-
$path bindImage <Shift-ButtonRelease-1> [list $cmd $path s %x %y]
233-
$path bindImage <Control-ButtonRelease-1> [list $cmd $path c %x %y]
231+
$path _bindImage <ButtonRelease-1> [list $cmd $path n %x %y]
232+
$path _bindImage <Shift-ButtonRelease-1> [list $cmd $path s %x %y]
233+
$path _bindImage <Control-ButtonRelease-1> [list $cmd $path c %x %y]
234234
}
235235
default {
236236
if {0 < [llength [ListBox::selection $path get]]} {
@@ -431,7 +431,7 @@ proc ListBox::itemconfigure { path item args } {
431431
} else {
432432
$path.c delete $idi
433433
$path.c create image $x0 $y0 -image $img -anchor w \
434-
-tags [list img i:$item]
434+
-tags [list img imgbind i:$item]
435435
}
436436
} else {
437437
$path.c delete $idi
@@ -473,30 +473,42 @@ proc ListBox::itemcget { path item option } {
473473

474474

475475
# ----------------------------------------------------------------------------
476-
# Command ListBox::bindText
476+
# Command ListBox::_bindText
477477
# ----------------------------------------------------------------------------
478-
proc ListBox::bindText { path event script } {
478+
proc ListBox::_bindText { path event script {tag click} } {
479479
if { $script != "" } {
480480
set map [list %W $path]
481481
set script [string map $map $script]
482482
append script " \[ListBox::_get_current [list $path]\]"
483483
}
484-
$path.c bind "click" $event $script
484+
$path.c bind $tag $event $script
485485
}
486486

487+
# ----------------------------------------------------------------------------
488+
# Command ListBox::bindText
489+
# ----------------------------------------------------------------------------
490+
proc ListBox::bindText { path event script } {
491+
_bindText $path $event $script clickbind
492+
}
487493

488494
# ----------------------------------------------------------------------------
489-
# Command ListBox::bindImage
495+
# Command ListBox::_bindImage
490496
# ----------------------------------------------------------------------------
491-
proc ListBox::bindImage { path event script } {
497+
proc ListBox::_bindImage { path event script {tag img} } {
492498
if { $script != "" } {
493499
set map [list %W $path]
494500
set script [string map $map $script]
495501
append script " \[ListBox::_get_current [list $path]\]"
496502
}
497-
$path.c bind "img" $event $script
503+
$path.c bind $tag $event $script
498504
}
499505

506+
# ----------------------------------------------------------------------------
507+
# Command ListBox::bindImage
508+
# ----------------------------------------------------------------------------
509+
proc ListBox::bindImage { path event script } {
510+
_bindImage $path $event $script imgbind
511+
}
500512

501513
# ----------------------------------------------------------------------------
502514
# Command ListBox::delete
@@ -1013,12 +1025,12 @@ proc ListBox::_draw_item {path item x0 x1 y bg selfill multi ww} {
10131025
-fill [_getoption $path $item -foreground] \
10141026
-font [_getoption $path $item -font] \
10151027
-anchor w \
1016-
-tags [list item n:$item click]]
1028+
-tags [list item n:$item click clickbind]]
10171029

10181030
if { $selfill && !$multi } {
10191031
set bbox [$path.c bbox n:$item]
10201032
set bbox [list 0 [lindex $bbox 1] $ww [lindex $bbox 3]]
1021-
set tags [list box b:$item click]
1033+
set tags [list box b:$item click clickbind]
10221034
$path.c create rect $bbox -fill $bg -width 0 -tags $tags
10231035
$path.c raise $i
10241036
}
@@ -1028,7 +1040,7 @@ proc ListBox::_draw_item {path item x0 x1 y bg selfill multi ww} {
10281040
-window $win -anchor w -tags [list win i:$item]
10291041
} elseif { [set img [Widget::getoption $path.$item -image]] != "" } {
10301042
$path.c create image [expr {$x0+$indent}] $y \
1031-
-image $img -anchor w -tags [list img i:$item]
1043+
-image $img -anchor w -tags [list img imgbind i:$item]
10321044
}
10331045

10341046
_set_help $path $item
@@ -1134,7 +1146,7 @@ proc ListBox::_redraw_selection { path } {
11341146
# With -selectfill, make box occupy full width of widget
11351147
set bbox [list 0 [lindex $bbox 1] $width [lindex $bbox 3]]
11361148
}
1137-
set tags [list sel s:$item click]
1149+
set tags [list sel s:$item click clickbind]
11381150
set id [$path.c create rectangle $bbox \
11391151
-fill $selbg -outline $selbg -tags $tags]
11401152
if {$selfg != ""} {

0 commit comments

Comments
 (0)