#12 grab_focus don't work ?!?!

closed
Masao Mutoh
ruby-gnome (11)
1
2002-09-10
2002-09-10
Anonymous
No

With the following code grab_focus does not work :
def initialize
vb = Gtk::VBox.new
@textwin = Gtk::Frame.new
@textwin.add(vb)

@scrollwin = Gtk::ScrolledWindow.new(nil, nil)
@scrollwin.set_policy(Gtk::POLICY_AUTOMATIC,
Gtk::POLICY_AUTOMATIC)

vb.pack_start(@scrollwin, true, true, 0)

@text = Gtk::Text.new
@text.set_editable(false)
@text.grab_focus

@scrollwin.add(@text)

@input = Gtk::Entry.new
@input.grab_focus
@input.signal_connect('activate') do
input
end
vb.pack_start(@input, false, true, 0)

@textwin.show_all
end

Discussion

  • Masao Mutoh
    Masao Mutoh
    2002-09-10

    • labels: --> ruby-gnome
    • priority: 5 --> 1
    • assigned_to: nobody --> mutoh
    • status: open --> wont-fix
     
  • Masao Mutoh
    Masao Mutoh
    2002-09-10

    Logged In: YES
    user_id=495147

    You should call Gtk::Widget#grab_focus after all widgets are
    taken up their position.

    require 'gtk'

    text1 = Gtk::Text.new
    text2 = Gtk::Text.new
    text2.set_editable(true)
    button = Gtk::Button.new("click")
    box = Gtk::VBox.new
    box.pack_start(text1, true, true, 10)
    box.pack_start(text2, true, true, 10)
    box.pack_start(button, true, true, 10)
    window = Gtk::Window.new
    window.add(box)
    text2.grab_focus

    window.show_all
    Gtk.main

    @text.set_editable(false) also can grab focus but you can't
    edit.
    You can confirm what widget is grabbed to press TAB key.

     
  • Masao Mutoh
    Masao Mutoh
    2002-09-10

    • status: wont-fix --> closed