summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjenglish@flightlab.com <jenglish>2010-05-27 19:27:03 (GMT)
committerjenglish@flightlab.com <jenglish>2010-05-27 19:27:03 (GMT)
commit8472cd659bd1cb1889202a1a9adee3a7541932e7 (patch)
treeb84a395875fc384baadf68a72d6eadf84f859bff /generic
parent96388f2bfaadc202305bca7550b7d68a2efc2443 (diff)
downloadtk-8472cd659bd1cb1889202a1a9adee3a7541932e7.zip
tk-8472cd659bd1cb1889202a1a9adee3a7541932e7.tar.gz
tk-8472cd659bd1cb1889202a1a9adee3a7541932e7.tar.bz2
ttk::treeview: [$tv tag bind $tag <...> {}] now removes binding completely.
Fixes [Bug 3006842] (although there's still a problem somewhere in Tk_CreateBinding()).
Diffstat (limited to 'generic')
-rw-r--r--generic/ttk/ttkTreeview.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c
index a023eaf..6672318 100644
--- a/generic/ttk/ttkTreeview.c
+++ b/generic/ttk/ttkTreeview.c
@@ -1,4 +1,4 @@
-/* $Id: ttkTreeview.c,v 1.38 2010/03/28 21:43:25 jenglish Exp $
+/* $Id: ttkTreeview.c,v 1.39 2010/05/27 19:27:04 jenglish Exp $
* Copyright (c) 2004, Joe English
*
* ttk::treeview widget implementation.
@@ -3005,6 +3005,8 @@ static int TreeviewTagBindCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
Treeview *tv = recordPtr;
+ Ttk_TagTable tagTable = tv->tree.tagTable;
+ Tk_BindingTable bindingTable = tv->tree.bindingTable;
Ttk_Tag tag;
if (objc < 4 || objc > 6) {
@@ -3012,37 +3014,40 @@ static int TreeviewTagBindCommand(
return TCL_ERROR;
}
- tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[3]);
+ tag = Ttk_GetTagFromObj(tagTable, objv[3]);
if (!tag) { return TCL_ERROR; }
if (objc == 4) { /* $tv tag bind $tag */
- Tk_GetAllBindings(interp, tv->tree.bindingTable, tag);
+ Tk_GetAllBindings(interp, bindingTable, tag);
} else if (objc == 5) { /* $tv tag bind $tag $sequence */
/* TODO: distinguish "no such binding" (OK) from "bad pattern" (ERROR)
*/
const char *script = Tk_GetBinding(interp,
- tv->tree.bindingTable, tag, Tcl_GetString(objv[4]));
+ bindingTable, tag, Tcl_GetString(objv[4]));
if (script != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(script,-1));
}
} else if (objc == 6) { /* $tv tag bind $tag $sequence $script */
const char *sequence = Tcl_GetString(objv[4]);
const char *script = Tcl_GetString(objv[5]);
- unsigned long mask = Tk_CreateBinding(interp,
- tv->tree.bindingTable, tag, sequence, script, 0);
- /* Test mask to make sure event is supported:
- */
- if (mask & (~TreeviewBindEventMask)) {
- Tk_DeleteBinding(interp, tv->tree.bindingTable, tag, sequence);
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "unsupported event ", sequence,
- "\nonly key, button, motion, and virtual events supported",
- NULL);
- return TCL_ERROR;
+ if (!*script) { /* Delete existing binding */
+ Tk_DeleteBinding(interp, bindingTable, tag, sequence);
+ } else {
+ unsigned long mask = Tk_CreateBinding(interp,
+ bindingTable, tag, sequence, script, 0);
+
+ /* Test mask to make sure event is supported:
+ */
+ if (mask & (~TreeviewBindEventMask)) {
+ Tk_DeleteBinding(interp, bindingTable, tag, sequence);
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, "unsupported event ", sequence,
+ "\nonly key, button, motion, and virtual events supported",
+ NULL);
+ return TCL_ERROR;
+ }
}
-
- return mask ? TCL_OK : TCL_ERROR;
}
return TCL_OK;
}