diff options
author | patthoyts <patthoyts@users.sourceforge.net> | 2009-05-14 12:04:40 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@users.sourceforge.net> | 2009-05-14 12:04:40 (GMT) |
commit | 019090556763927804b615cb9c6d43bd861af661 (patch) | |
tree | 0ad68c24412ee1b50f0fa96fc7982532193e03a7 /generic/tkButton.c | |
parent | 096b09da4b77f4052315e7830fdd36bc98685a36 (diff) | |
download | tk-019090556763927804b615cb9c6d43bd861af661.zip tk-019090556763927804b615cb9c6d43bd861af661.tar.gz tk-019090556763927804b615cb9c6d43bd861af661.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.c | 29 |
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; |