From: Hidetoshi NAGAI Date: 2009-12-09T08:48:00+09:00 Subject: Re: overriding key bindings in tktext From: Martin DeMello Subject: overriding key bindings in tktext Date: Wed, 9 Dec 2009 02:58:01 +0900 Message-ID: > Does tktext let me completely override bindings? For instance, if I > wanted to disable the enter key, editor.bind("Any-Key-Return") {} > doesn't do anything - the newline gets inserted. You have to break the evaluation of the widget's bindtag list. By default, the bindtag list is [_the_widget_, TkText, _toplevel_window_of_the_widget_, "all"]. You define a binding to _the_widget_. But after the callback, Tk evaluates bindings of TkText (depends on the order of bindtags list). You can break the evaluation of bindtags by editor.bind("Any-Key-Return"){...; break; ...} or editor.bind("Any-Key-Return"){...; Tk.callback_break; ...}. If the former has no effect (depends on Ruby or Ruby/Tk version), please use the latter. The latter should work on any version of Ruby/Tk. -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)