summaryrefslogtreecommitdiffstats
path: root/generic/tkButton.c
diff options
context:
space:
mode:
authorpatthoyts@users.sourceforge.net <patthoyts>2009-05-14 12:04:40 (GMT)
committerpatthoyts@users.sourceforge.net <patthoyts>2009-05-14 12:04:40 (GMT)
commit0c303a85c0f5ed57b4ddb2a68b3a531d699ceae7 (patch)
tree0ad68c24412ee1b50f0fa96fc7982532193e03a7 /generic/tkButton.c
parent06e383936a84f6aa562302eed4eee286abf36130 (diff)
downloadtk-0c303a85c0f5ed57b4ddb2a68b3a531d699ceae7.zip
tk-0c303a85c0f5ed57b4ddb2a68b3a531d699ceae7.tar.gz
tk-0c303a85c0f5ed57b4ddb2a68b3a531d699ceae7.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;