From: Hidetoshi NAGAI Date: 2005-05-26T06:39:46+09:00 Subject: Re: Tk read-only text box From: Hidetoshi NAGAI Subject: Re: Tk read-only text box Date: Wed, 25 May 2005 23:21:52 +0900 Message-ID: <20050525.232149.41634296.nagai@ai.kyutech.ac.jp> > Here is an example. > ---------------------------------------------------------------- > require 'tk' > t = TkText.new.pack > t.bindtags_unshift(b = TkBindTag.new) > b.bind('Key', proc{ Tk.callback_break }) > b.bind('Control-KeyPress-w', > proc{ Tk.callback_continue }) # continue to the next bindtag > b.bind('Control-KeyPress-y', proc{}) > b.bind('Control-KeyPress-c', proc{t.insert(:end, "Press Ctrl-C !!\n")}) > b.bind('Control-Alt-KeyPress-c', proc{exit}) > > t.insert(:end, "This is a test message.\n"); > > Tk.after(10000){t.insert(:end, "This is another test message.\n")} > > Tk.mainloop > ---------------------------------------------------------------- It goes without saying that the following is same to replace the standard callback function of the text widget. ---------------------------------------------------- b.bind('Control-KeyPress-y', proc{puts "Press Ctrl-y!!\n"; Tk.callback_break}) ---------------------------------------------------- -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)