From: Jacek Podkanski Date: 2002-09-10T04:32:18+09:00 Subject: Re: Ruby-gtk, Gtk::Text question. it worked KUBO Takehiro wrote: Thank you very much! I wonder sometimes why things seem so simple once you are shown solution. As you see, I'm trying to write simple editor in ruby. Any suggestions? > Hi, > > Jacek Podkanski writes: > >> LESS wrote: >> >>> Am Mon, 2002-09-09 um 13.51 schrieb Jacek Podkanski: >>>> Hi, >>>> What should I do to make my Gtk::Text widget accept keyboard input >>>> without need of clicking on it first? >>> >>> try text.set_editable(true) >>> text.grab_focus >>> >> >> Sorry, but it didn't work. Below is a program I'm trying to write. > > put @text.grab_focus after vbox.pack_start(@text,true,true). > >> class Text >> def initialize(vbox) >> @text=Gtk::Text.new >> >> @text.set_editable(true) >> @text.grab_focus #it didn't work here >> ################################# >> ####################################################################### >> >> #t='ala ma kota' >> #@text.insert_text(t,0) >> #@text.signal_connect("grab_focus") {puts 'you got focus now'} >> @text.signal_connect("key_press_event") {|w,e| >> $com.set_status('you pressed key *** '+e.keyval.to_s) >> #puts @text.has_focus?,'######' >> } >> vbox.pack_start(@text,true,true) >> end >> end#class > > Context diff: > ======================================================= > @@ -15,8 +15,6 @@ > @text=Gtk::Text.new > > @text.set_editable(true) > - @text.grab_focus #it didn't work here > ################################# > - > ####################################################################### > > #t='ala ma kota' > #@text.insert_text(t,0) > @@ -26,6 +24,7 @@ > #puts @text.has_focus?,'######' > } > vbox.pack_start(@text,true,true) > + @text.grab_focus #it works here. > end > end#class > class Menu > ======================================================= > Regards, -- Jacek Podkanski