summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--generic/tkListbox.c26
-rw-r--r--tests/listbox.test15
3 files changed, 33 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index e72af98..0b2c853 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2003-02-24 Jeff Hobbs <jeffh@ActiveState.com>
+ * generic/tkListbox.c (ListboxSelectionSubCmd):
+ * tests/listbox.test: Allow 'selection includes' to respond when
+ disabled (but only 'includes'). [Bug #632514]
+
* unix/tkUnixButton.c (TkpDisplayButton): Correct visual display
of disabled check/radiobutton to be more distinctive on unix.
* tests/unixButton.test: [Bug #669595] (hintermayer)
diff --git a/generic/tkListbox.c b/generic/tkListbox.c
index d11396f..78977d6 100644
--- a/generic/tkListbox.c
+++ b/generic/tkListbox.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: tkListbox.c,v 1.28 2002/08/05 04:30:39 dgp Exp $
+ * RCS: @(#) $Id: tkListbox.c,v 1.29 2003/02/25 02:07:25 hobbs Exp $
*/
#include "tkPort.h"
@@ -1042,14 +1042,10 @@ ListboxWidgetObjCmd(clientData, interp, objc, objv)
}
case COMMAND_SELECTION: {
- if (!(listPtr->state & STATE_NORMAL)) {
- break;
- }
-
result = ListboxSelectionSubCmd(interp, listPtr, objc, objv);
break;
}
-
+
case COMMAND_SIZE: {
char buf[TCL_INTEGER_SPACE];
if (objc != 2) {
@@ -1182,6 +1178,16 @@ ListboxSelectionSubCmd(interp, listPtr, objc, objv)
if (result != TCL_OK) {
return result;
}
+
+ /*
+ * Only allow 'selection includes' to respond if disabled. [Bug #632514]
+ */
+
+ if ((listPtr->state == STATE_DISABLED)
+ && (selCmdIndex != SELECTION_INCLUDES)) {
+ return TCL_OK;
+ }
+
switch (selCmdIndex) {
case SELECTION_ANCHOR: {
if (objc != 4) {
@@ -1207,11 +1213,9 @@ ListboxSelectionSubCmd(interp, listPtr, objc, objv)
Tcl_WrongNumArgs(interp, 3, objv, "index");
return TCL_ERROR;
}
- if (Tcl_FindHashEntry(listPtr->selection, (char *)first)) {
- Tcl_SetResult(interp, "1", TCL_STATIC);
- } else {
- Tcl_SetResult(interp, "0", TCL_STATIC);
- }
+ Tcl_SetObjResult(interp,
+ Tcl_NewBooleanObj((Tcl_FindHashEntry(listPtr->selection,
+ (char *)first) != NULL)));
result = TCL_OK;
break;
}
diff --git a/tests/listbox.test b/tests/listbox.test
index 5e69d64..37f5f30 100644
--- a/tests/listbox.test
+++ b/tests/listbox.test
@@ -6,7 +6,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: listbox.test,v 1.20 2002/07/14 05:48:46 dgp Exp $
+# RCS: @(#) $Id: listbox.test,v 1.21 2003/02/25 02:07:25 hobbs Exp $
package require tcltest 2.1
namespace import -force tcltest::configure
@@ -2132,6 +2132,19 @@ test listbox-28.3 {listbox -activestyle} {
.l cget -activestyle
} dotbox
+test listbox-29.1 {listbox selection behavior, -state disabled} {
+ destroy .l
+ listbox .l
+ .l insert end 1 2 3
+ .l selection set 2
+ set out [.l selection includes 2]
+ .l configure -state disabled
+ # still return 1 when disabled, because 'selection get' will work,
+ # but selection cannot be changed (new behavior since 8.4)
+ .l selection set 3
+ lappend out [.l selection includes 2] [.l curselection]
+} {1 1 2}
+
resetGridInfo
deleteWindows
option clear