summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorericm <ericm>2000-07-19 00:20:01 (GMT)
committerericm <ericm>2000-07-19 00:20:01 (GMT)
commitd046a8a0ca9b4b60ea496c1f63a59e71450ee100 (patch)
treeb7513cd89103b791aa1277037f363a5a93406efe
parentc06eec5511038a1f20095dc6d5512b6c65dfbe94 (diff)
downloadtk-d046a8a0ca9b4b60ea496c1f63a59e71450ee100.zip
tk-d046a8a0ca9b4b60ea496c1f63a59e71450ee100.tar.gz
tk-d046a8a0ca9b4b60ea496c1f63a59e71450ee100.tar.bz2
* library/tkfbox.tcl: Fixed keyboard navigation in the iconlist.
-rw-r--r--ChangeLog2
-rw-r--r--library/tkfbox.tcl75
2 files changed, 40 insertions, 37 deletions
diff --git a/ChangeLog b/ChangeLog
index 13b55b9..5c7985d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2000-07-18 Eric Melski <ericm@ajubasolutions.com>
+ * library/tkfbox.tcl: Fixed keyboard navigation in the iconlist.
+
* unix/configure.in (MAKE_LIB): Corrected definition of MAKE_LIB
for shared builds, with patch from Mike Hopkirk.
diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl
index d8d9be1..7044af0 100644
--- a/library/tkfbox.tcl
+++ b/library/tkfbox.tcl
@@ -11,7 +11,7 @@
# files by clicking on the file icons or by entering a filename
# in the "Filename:" entry.
#
-# RCS: @(#) $Id: tkfbox.tcl,v 1.21 2000/06/30 06:38:38 ericm Exp $
+# RCS: @(#) $Id: tkfbox.tcl,v 1.22 2000/07/19 00:20:02 ericm Exp $
#
# Copyright (c) 1994-1998 Sun Microsystems, Inc.
#
@@ -43,7 +43,13 @@ proc tkIconList_Index {w i} {
upvar #0 $w data
upvar #0 $w:itemList itemList
switch -regexp -- $i {
- "^[0-9]+$" {
+ "^-?[0-9]+$" {
+ if { $i < 0 } {
+ set i 0
+ }
+ if { $i >= [llength $data(list)] } {
+ set i [expr {[llength $data(list)] - 1}]
+ }
return $i
}
"^active$" {
@@ -70,7 +76,7 @@ proc tkIconList_Selection {w op args} {
switch -exact -- $op {
"anchor" {
if { [llength $args] == 1 } {
- set data(index,anchor) [lindex $args 0]
+ set data(index,anchor) [tkIconList_Index $w [lindex $args 0]]
} else {
return $data(index,anchor)
}
@@ -336,11 +342,12 @@ proc tkIconList_Add {w image items} {
foreach text $items {
set iTag [$data(canvas) create image 0 0 -image $image -anchor nw \
- -tags [list icon $data(numItems)]]
+ -tags [list icon $data(numItems) item$data(numItems)]]
set tTag [$data(canvas) create text 0 0 -text $text -anchor nw \
- -font $data(font) -tags [list text $data(numItems)]]
+ -font $data(font) \
+ -tags [list text $data(numItems) item$data(numItems)]]
set rTag [$data(canvas) create rect 0 0 0 0 -fill "" -outline "" \
- -tags [list rect $data(numItems)]]
+ -tags [list rect $data(numItems) item$data(numItems)]]
foreach {x1 y1 x2 y2} [$data(canvas) bbox $iTag] {
break
@@ -485,12 +492,11 @@ proc tkIconList_See {w rTag} {
return
}
- if {![info exists itemList($rTag)]} {
+ if { $rTag < 0 || $rTag >= [llength $data(list)] } {
return
}
-
- set bbox [$data(canvas) bbox $rTag]
+ set bbox [$data(canvas) bbox item$rTag]
set pad [expr {[$data(canvas) cget -highlightthickness] + \
[$data(canvas) cget -bd]}]
@@ -633,20 +639,17 @@ proc tkIconList_UpDown {w amount} {
return
}
- if {[string equal $data(curItem) {}]} {
- set rTag [lindex [lindex $data(list) 0] 2]
+ set curr [tkIconList_Curselection $w]
+ if { [llength $curr] == 0 } {
+ set i 0
} else {
- set oldRTag [lindex [lindex $data(list) $data(curItem)] 2]
- set rTag [lindex [lindex $data(list) [expr {$data(curItem)+$amount}]] 2]
- if {[string equal $rTag ""]} {
- set rTag $oldRTag
- }
- }
-
- if {[string compare $rTag ""]} {
- tkIconList_Select $w $rTag
- tkIconList_See $w $rTag
+ set i [tkIconList_Index $w anchor]
+ incr i $amount
}
+ tkIconList_Selection $w clear 0 end
+ tkIconList_Selection $w set $i
+ tkIconList_Selection $w anchor $i
+ tkIconList_See $w $i
}
# tkIconList_LeftRight --
@@ -663,21 +666,18 @@ proc tkIconList_LeftRight {w amount} {
if {![info exists data(list)]} {
return
}
- if {[string equal $data(curItem) {}]} {
- set rTag [lindex [lindex $data(list) 0] 2]
- } else {
- set oldRTag [lindex [lindex $data(list) $data(curItem)] 2]
- set newItem [expr {$data(curItem)+($amount*$data(itemsPerColumn))}]
- set rTag [lindex [lindex $data(list) $newItem] 2]
- if {[string equal $rTag ""]} {
- set rTag $oldRTag
- }
- }
- if {[string compare $rTag ""]} {
- tkIconList_Select $w $rTag
- tkIconList_See $w $rTag
+ set curr [tkIconList_Curselection $w]
+ if { [llength $curr] == 0 } {
+ set i 0
+ } else {
+ set i [tkIconList_Index $w anchor]
+ incr i [expr {$amount*$data(itemsPerColumn)}]
}
+ tkIconList_Selection $w clear 0 end
+ tkIconList_Selection $w set $i
+ tkIconList_Selection $w anchor $i
+ tkIconList_See $w $i
}
#----------------------------------------------------------------------
@@ -743,9 +743,10 @@ proc tkIconList_Goto {w text} {
}
if {$theIndex > -1} {
- set rTag [lindex [lindex $data(list) $theIndex] 2]
- tkIconList_Select $w $rTag
- tkIconList_See $w $rTag
+ tkIconList_Selection $w clear 0 end
+ tkIconList_Selection $w set $theIndex
+ tkIconList_Selection $w anchor $theIndex
+ tkIconList_See $w $theIndex
}
}