Hi,
What should I do to make my Gtk::Text widget accept keyboard input without
need of clicking on it first?
Is there any specific Ruby-gtk list?
···
–
Jacek Podkanski
Hi,
What should I do to make my Gtk::Text widget accept keyboard input without
need of clicking on it first?
Is there any specific Ruby-gtk list?
–
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
Is there any specific Ruby-gtk list?
there is a gnome-list on sourceforge.net
–
Jacek Podkanski
Harald Große
Am Mon, 2002-09-09 um 13.51 schrieb Jacek Podkanski:
Hi,
On Mon, 9 Sep 2002 21:05:54 +0900 LESS info@less.de 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_focusIs there any specific Ruby-gtk list?
there is a gnome-list on sourceforge.net
See Ruby-GNOME Language Bindings download | SourceForge.net
–
.:% Masao Mutohmutoh@highway.ne.jp
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.
################################################################
#!/usr/bin/ruby
require ‘gtk’
class Status_bar < Gtk::Label
def initialize(vbox,m=‘’)
@label=Gtk::Label.new(m)
vbox.pack_start(@label,false,false)
end
def message(m)
@label.set_text(m)
end
end#class
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
class Menu
def initialize(vbox)
#super ‘menu will go here’
@menubar=Gtk::MenuBar.new
vbox.pack_start(@menubar,false,false)
menubaritem = Gtk::MenuItem.new("File")
@menubar.append(menubaritem)
filemenu=Gtk::Menu.new#menu under 'File' that contains 'Quit' item
menubaritem.set_submenu(filemenu)
quit=Gtk::MenuItem.new('Quit')
filemenu.append(quit)
quit.signal_connect("button_press_event") {
puts 'you pressed Menu/File/Quit'
$com.quit
}
help=Gtk::MenuItem.new('Help')
@menubar.append(help)
helpmenu=Gtk::Menu.new
help.set_submenu(helpmenu)
about=Gtk::MenuItem.new 'About'
helpmenu.append(about)
about.signal_connect("button_press_event") {
$com.set_status('Author: Jacek Podkanski')
}
end
end#class
class Toolbar
def initialize(vbox)
@label=Gtk::Label.new(‘toolbar will be here’)
vbox.pack_start(@label,false,false)
end
end#class
class Com
#program in such way that you don’t need → attr_reader :ed
def initialize(edytorek); @ed=edytorek; end
def quit
puts ‘quitting’; exit
end
def set_status(m=‘’)
@ed.status.message(m)
end
end#class
###################################################################
class Edytorek
attr_reader :status
def initialize
$com=Com.new(self)
window = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL)
window.set_title(‘edytorek’)
window.signal_connect(“delete_event”) { $com.quit }
window.signal_connect(“destroy_event”) { $com.quit }
#window.signal_connect(“key_press_event”) {|w,e|
# $com.set_status('Nacisnales klawisz '+e.keyval.to_s)
#}
vbox=Gtk::VBox.new()
window.add(vbox)
@menu=Menu.new(vbox)
@toolbar=Toolbar.new(vbox)
@text=Text.new(vbox)
@status=Status_bar.new(vbox)
$com.set_status('statusbar will go here...')
window.show_all
#window.set_default_size( 200,200 )
window.set_uposition( 0,0 )
Gtk::main()
Jacek Podkanski
Hi,
Jacek Podkanski jacekpodkanski@supanet.com writes:
LESS wrote:
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_focusSorry, 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:
Am Mon, 2002-09-09 um 13.51 schrieb Jacek Podkanski:
=======================================================
@@ -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)
–
KUBO Takehiro
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 jacekpodkanski@supanet.com 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_focusSorry, 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#classContext 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
=======================================================
Jacek Podkanski