diff options
author | patthoyts <patthoyts@users.sourceforge.net> | 2009-05-14 11:54:00 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@users.sourceforge.net> | 2009-05-14 11:54:00 (GMT) |
commit | 0f9335814309741068e4d1326108c47d654c0d1d (patch) | |
tree | 016d4b507c3afcbc4f970d502c1581ac1c3fe230 /generic | |
parent | 3624cdf255546ee3aa2f5f8fa60216aede7cf0a6 (diff) | |
download | tk-0f9335814309741068e4d1326108c47d654c0d1d.zip tk-0f9335814309741068e4d1326108c47d654c0d1d.tar.gz tk-0f9335814309741068e4d1326108c47d654c0d1d.tar.bz2 |
[Bug 1923684]: checkbuttons must prefer off over the indeterminate state
If a checkbutton offvalue is the same as the tristate value we
should use the off state in preference. (andrey gusev)
Diffstat (limited to 'generic')
-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 8778b1d..fea680f 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.33 2008/11/08 22:52:29 dkf Exp $ + * RCS: @(#) $Id: tkButton.c,v 1.34 2009/05/14 11:54:00 patthoyts Exp $ */ #include "tkInt.h" @@ -1130,12 +1130,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, @@ -1618,7 +1629,7 @@ ButtonVarProc( valuePtr = Tcl_ObjGetVar2(interp, butPtr->selVarNamePtr, NULL, TCL_GLOBAL_ONLY); if (valuePtr == NULL) { - value = ""; + value = Tcl_GetString(butPtr->tristateValuePtr); } else { value = Tcl_GetString(valuePtr); } @@ -1628,6 +1639,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; |