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.
martin
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.
martin
Message-ID: <f93a6bcc0912080957w15722d93y9b9c1bbff9862d69@mail.gmail.com>
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.
From: Martin DeMello <martindemello@gmail.com>
Subject: overriding key bindings in tktext
Date: Wed, 9 Dec 2009 02:58:01 +0900
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
Thanks, that works beautifully!
martin
On Wed, Dec 9, 2009 at 5:17 AM, Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> wrote:
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.