1
1
# ----------------------------------------------------------------------------
2
2
# listbox.tcl
3
3
# 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 $
5
5
# ----------------------------------------------------------------------------
6
6
# Index of commands:
7
7
# - ListBox::create
@@ -200,37 +200,37 @@ proc ListBox::_configureSelectmode { path selectmode {previous none} } {
200
200
# clear current binding
201
201
switch -exact -- $previous {
202
202
single {
203
- $path bindText <Button-1> " "
204
- $path bindImage <Button-1> " "
203
+ $path _bindText <Button-1> " "
204
+ $path _bindImage <Button-1> " "
205
205
}
206
206
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> " "
210
210
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> " "
214
214
}
215
215
}
216
216
# set new bindings
217
217
switch -exact -- $selectmode {
218
218
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]
221
221
if {1 < [llength [ListBox::selection $path get]]} {
222
222
ListBox::selection $path clear
223
223
}
224
224
}
225
225
multiple {
226
226
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]
230
230
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]
234
234
}
235
235
default {
236
236
if {0 < [llength [ListBox::selection $path get]]} {
@@ -431,7 +431,7 @@ proc ListBox::itemconfigure { path item args } {
431
431
} else {
432
432
$path .c delete $idi
433
433
$path .c create image $x0 $y0 -image $img -anchor w \
434
- -tags [list img i:$item ]
434
+ -tags [list img imgbind i:$item ]
435
435
}
436
436
} else {
437
437
$path .c delete $idi
@@ -473,30 +473,42 @@ proc ListBox::itemcget { path item option } {
473
473
474
474
475
475
# ----------------------------------------------------------------------------
476
- # Command ListBox::bindText
476
+ # Command ListBox::_bindText
477
477
# ----------------------------------------------------------------------------
478
- proc ListBox::bindText { path event script } {
478
+ proc ListBox::_bindText { path event script {tag click} } {
479
479
if { $script != " " } {
480
480
set map [list %W $path ]
481
481
set script [string map $map $script ]
482
482
append script " \[ ListBox::_get_current [ list $path ] \] "
483
483
}
484
- $path .c bind " click " $event $script
484
+ $path .c bind $tag $event $script
485
485
}
486
486
487
+ # ----------------------------------------------------------------------------
488
+ # Command ListBox::bindText
489
+ # ----------------------------------------------------------------------------
490
+ proc ListBox::bindText { path event script } {
491
+ _bindText $path $event $script clickbind
492
+ }
487
493
488
494
# ----------------------------------------------------------------------------
489
- # Command ListBox::bindImage
495
+ # Command ListBox::_bindImage
490
496
# ----------------------------------------------------------------------------
491
- proc ListBox::bindImage { path event script } {
497
+ proc ListBox::_bindImage { path event script {tag img} } {
492
498
if { $script != " " } {
493
499
set map [list %W $path ]
494
500
set script [string map $map $script ]
495
501
append script " \[ ListBox::_get_current [ list $path ] \] "
496
502
}
497
- $path .c bind " img " $event $script
503
+ $path .c bind $tag $event $script
498
504
}
499
505
506
+ # ----------------------------------------------------------------------------
507
+ # Command ListBox::bindImage
508
+ # ----------------------------------------------------------------------------
509
+ proc ListBox::bindImage { path event script } {
510
+ _bindImage $path $event $script imgbind
511
+ }
500
512
501
513
# ----------------------------------------------------------------------------
502
514
# Command ListBox::delete
@@ -1013,12 +1025,12 @@ proc ListBox::_draw_item {path item x0 x1 y bg selfill multi ww} {
1013
1025
-fill [_getoption $path $item -foreground] \
1014
1026
-font [_getoption $path $item -font] \
1015
1027
-anchor w \
1016
- -tags [list item n:$item click]]
1028
+ -tags [list item n:$item click clickbind ]]
1017
1029
1018
1030
if { $selfill && !$multi } {
1019
1031
set bbox [$path .c bbox n:$item ]
1020
1032
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 ]
1022
1034
$path .c create rect $bbox -fill $bg -width 0 -tags $tags
1023
1035
$path .c raise $i
1024
1036
}
@@ -1028,7 +1040,7 @@ proc ListBox::_draw_item {path item x0 x1 y bg selfill multi ww} {
1028
1040
-window $win -anchor w -tags [list win i:$item ]
1029
1041
} elseif { [set img [Widget::getoption $path .$item -image]] != " " } {
1030
1042
$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 ]
1032
1044
}
1033
1045
1034
1046
_set_help $path $item
@@ -1134,7 +1146,7 @@ proc ListBox::_redraw_selection { path } {
1134
1146
# With -selectfill, make box occupy full width of widget
1135
1147
set bbox [list 0 [lindex $bbox 1] $width [lindex $bbox 3]]
1136
1148
}
1137
- set tags [list sel s:$item click]
1149
+ set tags [list sel s:$item click clickbind ]
1138
1150
set id [$path .c create rectangle $bbox \
1139
1151
-fill $selbg -outline $selbg -tags $tags ]
1140
1152
if {$selfg != " " } {
0 commit comments