diff options
author | patthoyts <patthoyts@noemail.net> | 2009-05-14 12:04:40 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@noemail.net> | 2009-05-14 12:04:40 (GMT) |
commit | 3f5c80bec3a8cf00e1a2682996fca67c7a2d5700 (patch) | |
tree | 0ad68c24412ee1b50f0fa96fc7982532193e03a7 | |
parent | ad51098537494d7106d448a7bd31d00a1bb2938e (diff) | |
download | tk-3f5c80bec3a8cf00e1a2682996fca67c7a2d5700.zip tk-3f5c80bec3a8cf00e1a2682996fca67c7a2d5700.tar.gz tk-3f5c80bec3a8cf00e1a2682996fca67c7a2d5700.tar.bz2 |
[Bug 1923684]: backported checkbutton fix for confused state when -offvalue equals -tristatevalue
FossilOrigin-Name: 0ee192bc625aceebec85d784aca47224ef0fc374
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tkButton.c | 29 |
2 files changed, 28 insertions, 6 deletions
@@ -1,5 +1,10 @@ 2009-05-14 Pat Thoyts <patthoyts@users.sourceforge.net> + * generic/tkButton.c: [Bug 1923684]: backported checkbutton fix + for confused state when -offvalue equals -tristatevalue + +2009-05-14 Pat Thoyts <patthoyts@users.sourceforge.net> + * doc/ttk_image.n: Backported support for the Vista theme. * doc/ttk_style.n: This requires the vsapi element engine, * doc/ttk_vsapi.n: the hover state and the theme script 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; |