From: nconway@... (Neil Conway) Date: 2001-10-18T06:32:29+09:00 Subject: [ruby-talk:22690] Re: Gtk::Text connect_signal key_press_event eat keystroke? On Thu, Oct 18, 2001 at 06:07:16AM +0900, Phlip wrote: > Rubies: > > In Gtk I want to handle a keystroke, and then remove it from the food chain. > > I call this from the initialize of a class derived from Gtk::Text: > > signal_connect ('key_press_event') { |w, e| > e.keyval = 0 if e.string == "\t" > } > > That should, for example, disable the Tab key for my hapless user. > > But e.keyval has no e.keyval= version, so the above does not execute. > > How do I censor a keystroke? My guess is to connect to the "insert-text" signal; according to the docs: The default signal handler for this signal will normally be responsible for inserting the text, so by connecting to this signal and then stopping the signal with gtk_signal_emit_stop(), it is possibly to modify the inserted text, or prevent it from being inserted entirely. However, it appears that gtk_signal_emit_stop() isn't implemented yet -- I'll take a look at it and see if I can get something in CVS tonight. There may be a better alternative, however -- that's just the first one I thought of. Cheers, Neil