summaryrefslogtreecommitdiffstats
path: root/generic/tkButton.c
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2009-05-14 12:04:40 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2009-05-14 12:04:40 (GMT)
commit5a966747464966ed42006979a0db4c42d66f0799 (patch)
tree0ad68c24412ee1b50f0fa96fc7982532193e03a7 /generic/tkButton.c
parentd6ae9ac6b68ade20d79d00780b721ba419701f0b (diff)
downloadtk-5a966747464966ed42006979a0db4c42d66f0799.zip
tk-5a966747464966ed42006979a0db4c42d66f0799.tar.gz
tk-5a966747464966ed42006979a0db4c42d66f0799.tar.bz2
[Bug 1923684]: backported checkbutton fix for confused state when -offvalue equals -tristatevalue
Diffstat (limited to 'generic/tkButton.c')
-rw-r--r--generic/tkButton.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/generic/tkButton.c b/generic/tkButton.c
index 334a54b..a132dd2 100644
--- a/generic/tkButton.c
+++ b/generic/tkButton.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: tkButton.c,v 1.28 2007/12/13 15:24:13 dgp Exp $
+ * RCS: @(#) $Id: tkButton.c,v 1.28.2.1 2009/05/14 12:04:40 patthoyts Exp $
*/
#include "tkInt.h"
@@ -1133,12 +1133,23 @@ ConfigureButton(
butPtr->flags &= ~SELECTED;
butPtr->flags &= ~TRISTATED;
if (valuePtr != NULL) {
- if (strcmp(Tcl_GetString(valuePtr),
- Tcl_GetString(butPtr->onValuePtr)) == 0) {
+ const char *value = Tcl_GetString(valuePtr);
+ if (strcmp(value, Tcl_GetString(butPtr->onValuePtr)) == 0) {
butPtr->flags |= SELECTED;
- } else if (strcmp(Tcl_GetString(valuePtr),
+ } else if (strcmp(value,
Tcl_GetString(butPtr->tristateValuePtr)) == 0) {
- butPtr->flags |= TRISTATED;
+ butPtr->flags |= TRISTATED;
+
+ /*
+ * For checkbuttons if the tristate value is the
+ * same as the offvalue then prefer off to tristate
+ */
+
+ if (butPtr->offValuePtr
+ && strcmp(value,
+ Tcl_GetString(butPtr->offValuePtr)) == 0) {
+ butPtr->flags &= ~TRISTATED;
+ }
}
} else {
if (Tcl_ObjSetVar2(interp, namePtr, NULL,
@@ -1623,7 +1634,7 @@ ButtonVarProc(
valuePtr = Tcl_GetVar2Ex(interp, name, NULL, TCL_GLOBAL_ONLY);
if (valuePtr == NULL) {
- value = "";
+ value = Tcl_GetString(butPtr->tristateValuePtr);
} else {
value = Tcl_GetString(valuePtr);
}
@@ -1633,6 +1644,12 @@ ButtonVarProc(
}
butPtr->flags |= SELECTED;
butPtr->flags &= ~TRISTATED;
+ } else if (butPtr->offValuePtr
+ && strcmp(value, Tcl_GetString(butPtr->offValuePtr)) == 0) {
+ if (!(butPtr->flags & (SELECTED | TRISTATED))) {
+ return NULL;
+ }
+ butPtr->flags &= ~(SELECTED | TRISTATED);
} else if (strcmp(value, Tcl_GetString(butPtr->tristateValuePtr)) == 0) {
if (butPtr->flags & TRISTATED) {
return NULL;