How to unbind default bindings from a widget
bind, tcl, tk-toolkit, widget
Solution
Tk has different binding classes (called “bindtags”) that it attaches its bindings to. By default, each widget has:
- The bindtag with the same name as the widget. These are the normal ones for application code.
- The bindtag with the same name as the class of the widget (e.g., `Button` for a button, `Canvas` for a canvas). These are usually left to Tk's defaults; removing things from here will likely break other parts of your code.
- The bindtag with the same name as the toplevel containing the widget (except for toplevels). These are for per-dialog hotkeys, that sort of thing.
- The global bindtag, `all`. These handle a few “backstop” things but are not usually used.
Only at most one binding from each bindtag is used; Tk prefers to use the most specific one.
Removing a binding from one bindtag does not mean that the event will not be processed; a binding on another bindtag might still pick it up. Trying to hack around the other bindtags to fool the code is not going to be satisfactory. However, if a binding on one tag finishes with a `break`, it prevents further bindtags from being tried; it terminates processing early. This makes it easy to mask specific events:
bind .c <Up> break
Tk uses this sort of masking trick in a few places inside itself…
Problem
I'm having a hard time understating how to unbind events. I know the basic on unbinding your own binds ``` bind .c <Up> {magic code} bind .c <Up> {} ``` I really want to know how to remove binds from pre-binded widget. example the Text widget comes with the up key bond to move up, how do I remove that? So when the user hits the key nothing happen. And is there a way to remove all binds from a widget? (no particle reason just want to know.) And I Read that this should work, for unbind a single bind ``` bind all <Up> {} ``` ("Up" is the up arrow key for OS X) but it didn't for me. :( Sorry if this seem like a dumb questions but bind has been tripping me up lately. Thank you in advance.