|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bind Listbox <1> { |
|
if {[winfo exists %W]} { |
|
tk::ListboxBeginSelect %W [%W index @%x,%y] 1 |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
bind Listbox <Double-1> { |
|
|
|
} |
|
|
|
bind Listbox <B1-Motion> { |
|
set tk::Priv(x) %x |
|
set tk::Priv(y) %y |
|
tk::ListboxMotion %W [%W index @%x,%y] |
|
} |
|
bind Listbox <ButtonRelease-1> { |
|
tk::CancelRepeat |
|
%W activate @%x,%y |
|
} |
|
bind Listbox <Shift-1> { |
|
tk::ListboxBeginExtend %W [%W index @%x,%y] |
|
} |
|
bind Listbox <Control-1> { |
|
tk::ListboxBeginToggle %W [%W index @%x,%y] |
|
} |
|
bind Listbox <B1-Leave> { |
|
set tk::Priv(x) %x |
|
set tk::Priv(y) %y |
|
tk::ListboxAutoScan %W |
|
} |
|
bind Listbox <B1-Enter> { |
|
tk::CancelRepeat |
|
} |
|
|
|
bind Listbox <<PrevLine>> { |
|
tk::ListboxUpDown %W -1 |
|
} |
|
bind Listbox <<SelectPrevLine>> { |
|
tk::ListboxExtendUpDown %W -1 |
|
} |
|
bind Listbox <<NextLine>> { |
|
tk::ListboxUpDown %W 1 |
|
} |
|
bind Listbox <<SelectNextLine>> { |
|
tk::ListboxExtendUpDown %W 1 |
|
} |
|
bind Listbox <<PrevChar>> { |
|
%W xview scroll -1 units |
|
} |
|
bind Listbox <<PrevWord>> { |
|
%W xview scroll -1 pages |
|
} |
|
bind Listbox <<NextChar>> { |
|
%W xview scroll 1 units |
|
} |
|
bind Listbox <<NextWord>> { |
|
%W xview scroll 1 pages |
|
} |
|
bind Listbox <Prior> { |
|
%W yview scroll -1 pages |
|
%W activate @0,0 |
|
} |
|
bind Listbox <Next> { |
|
%W yview scroll 1 pages |
|
%W activate @0,0 |
|
} |
|
bind Listbox <Control-Prior> { |
|
%W xview scroll -1 pages |
|
} |
|
bind Listbox <Control-Next> { |
|
%W xview scroll 1 pages |
|
} |
|
bind Listbox <<LineStart>> { |
|
%W xview moveto 0 |
|
} |
|
bind Listbox <<LineEnd>> { |
|
%W xview moveto 1 |
|
} |
|
bind Listbox <Control-Home> { |
|
%W activate 0 |
|
%W see 0 |
|
%W selection clear 0 end |
|
%W selection set 0 |
|
tk::FireListboxSelectEvent %W |
|
} |
|
bind Listbox <Control-Shift-Home> { |
|
tk::ListboxDataExtend %W 0 |
|
} |
|
bind Listbox <Control-End> { |
|
%W activate end |
|
%W see end |
|
%W selection clear 0 end |
|
%W selection set end |
|
tk::FireListboxSelectEvent %W |
|
} |
|
bind Listbox <Control-Shift-End> { |
|
tk::ListboxDataExtend %W [%W index end] |
|
} |
|
bind Listbox <<Copy>> { |
|
if {[selection own -displayof %W] eq "%W"} { |
|
clipboard clear -displayof %W |
|
clipboard append -displayof %W [selection get -displayof %W] |
|
} |
|
} |
|
bind Listbox <space> { |
|
tk::ListboxBeginSelect %W [%W index active] |
|
} |
|
bind Listbox <<Invoke>> { |
|
tk::ListboxBeginSelect %W [%W index active] |
|
} |
|
bind Listbox <Select> { |
|
tk::ListboxBeginSelect %W [%W index active] |
|
} |
|
bind Listbox <Control-Shift-space> { |
|
tk::ListboxBeginExtend %W [%W index active] |
|
} |
|
bind Listbox <Shift-Select> { |
|
tk::ListboxBeginExtend %W [%W index active] |
|
} |
|
bind Listbox <Escape> { |
|
tk::ListboxCancel %W |
|
} |
|
bind Listbox <<SelectAll>> { |
|
tk::ListboxSelectAll %W |
|
} |
|
bind Listbox <<SelectNone>> { |
|
if {[%W cget -selectmode] ne "browse"} { |
|
%W selection clear 0 end |
|
tk::FireListboxSelectEvent %W |
|
} |
|
} |
|
|
|
|
|
|
|
bind Listbox <2> { |
|
%W scan mark %x %y |
|
} |
|
bind Listbox <B2-Motion> { |
|
%W scan dragto %x %y |
|
} |
|
|
|
|
|
|
|
|
|
|
|
if {[tk windowingsystem] eq "aqua"} { |
|
bind Listbox <MouseWheel> { |
|
%W yview scroll [expr {- (%D)}] units |
|
} |
|
bind Listbox <Option-MouseWheel> { |
|
%W yview scroll [expr {-10 * (%D)}] units |
|
} |
|
bind Listbox <Shift-MouseWheel> { |
|
%W xview scroll [expr {- (%D)}] units |
|
} |
|
bind Listbox <Shift-Option-MouseWheel> { |
|
%W xview scroll [expr {-10 * (%D)}] units |
|
} |
|
} else { |
|
bind Listbox <MouseWheel> { |
|
%W yview scroll [expr {- (%D / 120) * 4}] units |
|
} |
|
bind Listbox <Shift-MouseWheel> { |
|
%W xview scroll [expr {- (%D / 120) * 4}] units |
|
} |
|
} |
|
|
|
if {"x11" eq [tk windowingsystem]} { |
|
|
|
|
|
|
|
|
|
bind Listbox <4> { |
|
if {!$tk_strictMotif} { |
|
%W yview scroll -5 units |
|
} |
|
} |
|
bind Listbox <Shift-4> { |
|
if {!$tk_strictMotif} { |
|
%W xview scroll -5 units |
|
} |
|
} |
|
bind Listbox <5> { |
|
if {!$tk_strictMotif} { |
|
%W yview scroll 5 units |
|
} |
|
} |
|
bind Listbox <Shift-5> { |
|
if {!$tk_strictMotif} { |
|
%W xview scroll 5 units |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::ListboxBeginSelect {w el {focus 1}} { |
|
variable ::tk::Priv |
|
if {[$w cget -selectmode] eq "multiple"} { |
|
if {[$w selection includes $el]} { |
|
$w selection clear $el |
|
} else { |
|
$w selection set $el |
|
} |
|
} else { |
|
$w selection clear 0 end |
|
$w selection set $el |
|
$w selection anchor $el |
|
set Priv(listboxSelection) {} |
|
set Priv(listboxPrev) $el |
|
} |
|
tk::FireListboxSelectEvent $w |
|
|
|
if {$focus && [winfo exists $w] && [$w cget -state] eq "normal"} { |
|
focus $w |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::ListboxMotion {w el} { |
|
variable ::tk::Priv |
|
if {$el == $Priv(listboxPrev)} { |
|
return |
|
} |
|
set anchor [$w index anchor] |
|
switch [$w cget -selectmode] { |
|
browse { |
|
$w selection clear 0 end |
|
$w selection set $el |
|
set Priv(listboxPrev) $el |
|
tk::FireListboxSelectEvent $w |
|
} |
|
extended { |
|
set i $Priv(listboxPrev) |
|
if {$i eq ""} { |
|
set i $el |
|
$w selection set $el |
|
} |
|
if {[$w selection includes anchor]} { |
|
$w selection clear $i $el |
|
$w selection set anchor $el |
|
} else { |
|
$w selection clear $i $el |
|
$w selection clear anchor $el |
|
} |
|
if {![info exists Priv(listboxSelection)]} { |
|
set Priv(listboxSelection) [$w curselection] |
|
} |
|
while {($i < $el) && ($i < $anchor)} { |
|
if {[lsearch $Priv(listboxSelection) $i] >= 0} { |
|
$w selection set $i |
|
} |
|
incr i |
|
} |
|
while {($i > $el) && ($i > $anchor)} { |
|
if {[lsearch $Priv(listboxSelection) $i] >= 0} { |
|
$w selection set $i |
|
} |
|
incr i -1 |
|
} |
|
set Priv(listboxPrev) $el |
|
tk::FireListboxSelectEvent $w |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::ListboxBeginExtend {w el} { |
|
if {[$w cget -selectmode] eq "extended"} { |
|
if {[$w selection includes anchor]} { |
|
ListboxMotion $w $el |
|
} else { |
|
|
|
ListboxBeginSelect $w $el |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::ListboxBeginToggle {w el} { |
|
variable ::tk::Priv |
|
if {[$w cget -selectmode] eq "extended"} { |
|
set Priv(listboxSelection) [$w curselection] |
|
set Priv(listboxPrev) $el |
|
$w selection anchor $el |
|
if {[$w selection includes $el]} { |
|
$w selection clear $el |
|
} else { |
|
$w selection set $el |
|
} |
|
tk::FireListboxSelectEvent $w |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::ListboxAutoScan {w} { |
|
variable ::tk::Priv |
|
if {![winfo exists $w]} return |
|
set x $Priv(x) |
|
set y $Priv(y) |
|
if {$y >= [winfo height $w]} { |
|
$w yview scroll 1 units |
|
} elseif {$y < 0} { |
|
$w yview scroll -1 units |
|
} elseif {$x >= [winfo width $w]} { |
|
$w xview scroll 2 units |
|
} elseif {$x < 0} { |
|
$w xview scroll -2 units |
|
} else { |
|
return |
|
} |
|
ListboxMotion $w [$w index @$x,$y] |
|
set Priv(afterId) [after 50 [list tk::ListboxAutoScan $w]] |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::ListboxUpDown {w amount} { |
|
variable ::tk::Priv |
|
$w activate [expr {[$w index active] + $amount}] |
|
$w see active |
|
switch [$w cget -selectmode] { |
|
browse { |
|
$w selection clear 0 end |
|
$w selection set active |
|
tk::FireListboxSelectEvent $w |
|
} |
|
extended { |
|
$w selection clear 0 end |
|
$w selection set active |
|
$w selection anchor active |
|
set Priv(listboxPrev) [$w index active] |
|
set Priv(listboxSelection) {} |
|
tk::FireListboxSelectEvent $w |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::ListboxExtendUpDown {w amount} { |
|
variable ::tk::Priv |
|
if {[$w cget -selectmode] ne "extended"} { |
|
return |
|
} |
|
set active [$w index active] |
|
if {![info exists Priv(listboxSelection)]} { |
|
$w selection set $active |
|
set Priv(listboxSelection) [$w curselection] |
|
} |
|
$w activate [expr {$active + $amount}] |
|
$w see active |
|
ListboxMotion $w [$w index active] |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::ListboxDataExtend {w el} { |
|
set mode [$w cget -selectmode] |
|
if {$mode eq "extended"} { |
|
$w activate $el |
|
$w see $el |
|
if {[$w selection includes anchor]} { |
|
ListboxMotion $w $el |
|
} |
|
} elseif {$mode eq "multiple"} { |
|
$w activate $el |
|
$w see $el |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::ListboxCancel w { |
|
variable ::tk::Priv |
|
if {[$w cget -selectmode] ne "extended"} { |
|
return |
|
} |
|
set first [$w index anchor] |
|
set last $Priv(listboxPrev) |
|
if {$last eq ""} { |
|
|
|
return |
|
} |
|
if {$first > $last} { |
|
set tmp $first |
|
set first $last |
|
set last $tmp |
|
} |
|
$w selection clear $first $last |
|
while {$first <= $last} { |
|
if {[lsearch $Priv(listboxSelection) $first] >= 0} { |
|
$w selection set $first |
|
} |
|
incr first |
|
} |
|
tk::FireListboxSelectEvent $w |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::ListboxSelectAll w { |
|
set mode [$w cget -selectmode] |
|
if {$mode eq "single" || $mode eq "browse"} { |
|
$w selection clear 0 end |
|
$w selection set active |
|
} else { |
|
$w selection set 0 end |
|
} |
|
tk::FireListboxSelectEvent $w |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::FireListboxSelectEvent w { |
|
if {[$w cget -state] eq "normal"} { |
|
event generate $w <<ListboxSelect>> |
|
} |
|
} |
|
|