diff options
author | ericm <ericm> | 1999-11-24 01:09:07 (GMT) |
---|---|---|
committer | ericm <ericm> | 1999-11-24 01:09:07 (GMT) |
commit | abcfd77cbde42a883ece9a8db050e42b6ef9c45a (patch) | |
tree | 8b0902880bc85aa2e058c060030c624d97c571a3 | |
parent | be89e43c7fbc9554b9b1daa5a2ad02eb3be030b7 (diff) | |
download | tk-abcfd77cbde42a883ece9a8db050e42b6ef9c45a.zip tk-abcfd77cbde42a883ece9a8db050e42b6ef9c45a.tar.gz tk-abcfd77cbde42a883ece9a8db050e42b6ef9c45a.tar.bz2 |
* tests/listbox.test: Added a test to check that the topIndex is
update when items are removed from the listvar variable.
* generic/tkListbox.c: Added a check the updates the topIndex when
items are removed from the listvar variable.
-rw-r--r-- | generic/tkListbox.c | 8 | ||||
-rw-r--r-- | tests/listbox.test | 21 |
2 files changed, 27 insertions, 2 deletions
diff --git a/generic/tkListbox.c b/generic/tkListbox.c index ced0620..50e7652 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkListbox.c,v 1.12 1999/11/24 00:20:13 ericm Exp $ + * RCS: @(#) $Id: tkListbox.c,v 1.13 1999/11/24 01:09:07 ericm Exp $ */ #include "tkPort.h" @@ -3195,6 +3195,12 @@ ListboxListVarProc(clientData, interp, name1, name2, flags) if (oldLength != listPtr->nElements) { listPtr->flags |= UPDATE_V_SCROLLBAR; + if (listPtr->topIndex > (listPtr->nElements - listPtr->fullLines)) { + listPtr->topIndex = listPtr->nElements - listPtr->fullLines; + if (listPtr->topIndex < 0) { + listPtr->topIndex = 0; + } + } } /* diff --git a/tests/listbox.test b/tests/listbox.test index 3a20c07..886dfe1 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -6,7 +6,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: listbox.test,v 1.10 1999/11/24 00:20:14 ericm Exp $ +# RCS: @(#) $Id: listbox.test,v 1.11 1999/11/24 01:09:08 ericm Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -1896,6 +1896,25 @@ test listbox-21.15 {ListboxListVarProc, update vertical scrollbar} { update set log } [list {y 0 1} {y 0 0.5}] +test listbox-21.16 {ListboxListVarProc, update vertical scrollbar} { + catch {destroy .l} + catch {unset x} + listbox .l -listvar x -height 3 + pack .l + update + set x [list 0 1 2 3 4 5] + .l yview scroll 3 units + update + set result {} + lappend result [.l yview] + set x [lreplace $x 3 3] + set x [lreplace $x 3 3] + set x [lreplace $x 3 3] + update + lappend result [.l yview] + set result +} [list {0.5 1} {0 1}] + # UpdateHScrollbar test listbox-22.1 {UpdateHScrollbar} { catch {destroy .l} |