Tk Library Source Code

Artifact [690776c486]
Login

Artifact 690776c4869a08820eb50d4ea82b387cc7de0e35:

Attachment "455732.diff" to ticket [455732ffff] added by andreas_kupries 2001-09-07 02:31:08.
? Makefile
? config.status
? pkgIndex.tcl
? configure
? config.cache
? config.log
Index: mclistbox.tcl
===================================================================
RCS file: /cvsroot/tcllib/mclistbox/mclistbox.tcl,v
retrieving revision 1.33
diff -u -r1.33 mclistbox.tcl
--- mclistbox.tcl	2000/09/25 05:08:08	1.33
+++ mclistbox.tcl	2001/09/06 19:28:45
@@ -1202,6 +1202,29 @@
 
 }
 
+# ::mclistbox::FirstVisibleColumn --
+#
+#    this proc returns the id of the first visible column.
+#
+# Arguments:
+#
+#    w       widget pathname
+#
+# Results:
+#
+#    a string
+
+proc ::mclistbox::FirstVisibleColumn {w} {
+    upvar ::mclistbox::${w}::misc      misc
+    upvar ::mclistbox::${w}::options      options
+
+    foreach id $misc(columns) {
+	if {$options($id:-visible)} {break}
+    }
+
+    return $id
+}
+
 # ::mclistbox::MassageIndex --
 #
 #    this proc massages indicies of the form @x,y such that 
@@ -1223,7 +1246,7 @@
     upvar ::mclistbox::${w}::misc      misc
 
     if {[regexp {@([0-9]+),([0-9]+)} $index matchvar x y]} {
-	set id [lindex $misc(columns) 0]
+	set id [FirstVisibleColumn $w]
 	
 	incr y -[winfo y $widgets(listbox$id)]
 	incr y -[winfo y $widgets(frame$id)]
@@ -1356,7 +1379,7 @@
 	    # to account for the label, if any.
 	    set index [::mclistbox::MassageIndex $w [lindex $args 0]]
 
-	    set id [lindex $misc(columns) 0]
+	    set id [FirstVisibleColumn $w]
 
 	    # we can get the x, y, and height from the first 
 	    # column.
@@ -1582,8 +1605,12 @@
 	    }
 
 	    set index [::mclistbox::MassageIndex $w [lindex $args 0]]
-	    set id [lindex $misc(columns) 0]
 
+	    # Select a visible column to convert the screen location
+	    # into row ... Invisible columns are not mapped and can't
+	    # do this. They always returns row 0.
+
+	    set id     [FirstVisibleColumn $w]
 	    set result [$widgets(listbox$id) index $index]
 	}
 
@@ -1710,7 +1737,7 @@
 			error "$prefix selection $subcommand index"
 		    }
 		    set index [::mclistbox::MassageIndex $w [lindex $args 0]]
-		    set id [lindex $misc(columns) 0]
+		    set id [FirstVisibleColumn $w]
 		    set result [$widgets(listbox$id) selection includes $index]
 		}