summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--generic/tkEntry.c39
-rw-r--r--tests/spinbox.test17
3 files changed, 45 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 1d2a816..3473ad1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2002-07-25 Jeff Hobbs <jeffh@ActiveState.com>
+ * tests/spinbox.test: added spinbox-22.[1-3]
+ * generic/tkEntry.c (ConfigureEntry): made the textvariable value
+ take precedence over changed -from/-to values, unless it must be
+ constrained. [Bug #559078]
+
* library/spinbox.tcl (MouseSelect): when not in the entry, just
return instead of invoking - ButtonUp handles invoking already.
[Bug #499168]
diff --git a/generic/tkEntry.c b/generic/tkEntry.c
index 7d78d8a..a9bd94e 100644
--- a/generic/tkEntry.c
+++ b/generic/tkEntry.c
@@ -1,18 +1,20 @@
/*
* Entry.c --
*
- * This module implements entry widgets for the Tk
- * toolkit. An entry displays a string and allows
- * the string to be edited.
+ * This module implements entry and spinbox widgets for the Tk toolkit.
+ * An entry displays a string and allows the string to be edited.
+ * A spinbox expands on the entry by adding up/down buttons that control
+ * the value of the entry widget.
*
* Copyright (c) 1990-1994 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
* Copyright (c) 2000 Ajuba Solutions.
+ * Copyright (c) 2002 ActiveState Corporation.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkEntry.c,v 1.29 2002/07/24 18:30:55 hobbs Exp $
+ * RCS: @(#) $Id: tkEntry.c,v 1.30 2002/07/25 21:19:01 hobbs Exp $
*/
#include "tkInt.h"
@@ -1590,6 +1592,22 @@ ConfigureEntry(interp, entryPtr, objc, objv, flags)
Tk_FreeSavedOptions(&savedOptions);
}
+ /*
+ * If the entry is tied to the value of a variable, create the variable if
+ * it doesn't exist, and set the entry's value from the variable's value.
+ */
+
+ if (entryPtr->textVarName != NULL) {
+ CONST char *value;
+
+ value = Tcl_GetVar(interp, entryPtr->textVarName, TCL_GLOBAL_ONLY);
+ if (value == NULL) {
+ EntryValueChanged(entryPtr, NULL);
+ } else {
+ EntrySetValue(entryPtr, value);
+ }
+ }
+
if (entryPtr->type == TK_SPINBOX) {
ComputeFormat(sbPtr);
@@ -1631,20 +1649,11 @@ ConfigureEntry(interp, entryPtr, objc, objv, flags)
}
/*
- * If the entry is tied to the value of a variable, then set up
- * a trace on the variable's value, create the variable if it doesn't
- * exist, and set the entry's value from the variable's value.
+ * Set up a trace on the variable's value after we've possibly
+ * constrained the value according to new -from/-to values.
*/
if (entryPtr->textVarName != NULL) {
- CONST char *value;
-
- value = Tcl_GetVar(interp, entryPtr->textVarName, TCL_GLOBAL_ONLY);
- if (value == NULL) {
- EntryValueChanged(entryPtr, NULL);
- } else {
- EntrySetValue(entryPtr, value);
- }
Tcl_TraceVar(interp, entryPtr->textVarName,
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
EntryTextVarProc, (ClientData) entryPtr);
diff --git a/tests/spinbox.test b/tests/spinbox.test
index 0a576d3..74c81a6 100644
--- a/tests/spinbox.test
+++ b/tests/spinbox.test
@@ -4,7 +4,7 @@
# Copyright (c) 1998-2000 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: spinbox.test,v 1.3 2002/07/13 20:28:35 dgp Exp $
+# RCS: @(#) $Id: spinbox.test,v 1.4 2002/07/25 21:19:01 hobbs Exp $
package require tcltest 2.1
namespace import -force tcltest::configure
@@ -1557,6 +1557,21 @@ test spinbox-21.1 {spinbox button, out of range checking} {
} {-10 20 20 -10 -10 -10 20 20 18 -10 -10 -8 -10 -8 -10 20 18 20}
+test spinbox-22.1 {spinbox config, -from changes SF bug 559078} {
+ set val 5
+ destroy .s
+ spinbox .s -from 1 -to 10 -textvariable val
+ set val
+} {5}
+test spinbox-22.2 {spinbox config, -from changes SF bug 559078} {
+ .s configure -from 3 -to 10
+ set val
+} {5}
+test spinbox-22.3 {spinbox config, -from changes SF bug 559078} {
+ .s configure -from 6 -to 10
+ set val
+} {6}
+
destroy .e
catch {unset ::e ::vVals}