Focus on TextCtrl

Hello.
I have a problem with set focus on a TextCtrl in wxRuby.
I must do something like
Login TextCtrl and set focus on a next TextCtrl by clicking Tab key.

I’m find something like this.
somebody have a same problem

If I create a window containing two TextCtrl widgets, enter text in
one, and press the tab key, focus should move to the other one. That
doesn’t happen automatically. Is there some configuration I have to do
to make that happen?
maybe it will more clear to explain

Here is a sample code for this problem

@login_field = Wx::TextCtrl.new(@loginokno, -1, ‘’,Wx::Point.new(30,60),
Wx::Size.new(150,25))
@haslo_field = Wx::TextCtrl.new(@loginokno, -1,
‘’,Wx::Point.new(30,110), Wx::Size.new(150,25))
@lastname_field = Wx::TextCtrl.new(@loginokno, -1,
‘’,Wx::Point.new(30,160), Wx::Size.new(150,25))
@login_field.set_focus
@login_field.evt_key_down { |evt| on_log_key_down(evt) }
@haslo_field.evt_key_down { |evt| on_pas_key_down(evt) }

def on_log_key_down(evt)
keycode = evt.get_key_code()
if (keycode == 9)
@haslo_field.set_focus
else
evt.skip()
end
end

def on_pas_key_down(evt)
keycode = evt.get_key_code()
if (keycode == 9)
@lastname_field.set_focus
else
evt.skip()
end
end

Hi

Anton K. wrote:

If I create a window containing two TextCtrl widgets, enter text in
one, and press the tab key, focus should move to the other one. That
doesn’t happen automatically. Is there some configuration I have to do
to make that happen?
Arrange the TextCtrl widgets within a Wx::Panel, and then tabbing should
work automatically. Panel organises a group of widgets so that the
operating system knows which to tab between. For example:


require ‘wx’

Wx::App.run do
frame = Wx::Frame.new(nil, :title => ‘text tab’)
panel = Wx::Panel.new(frame)
txt1 = Wx::TextCtrl.new(panel, :pos => [ 10, 10 ])
txt2 = Wx::TextCtrl.new(panel, :pos => [ 10, 50 ])
frame.show
end


Using Wx::Panel is also recommended because it ensures the frame has the
right background colour, esp on Windows.

alex

Thank you very match.
your code sample is shorter and changing focus with Tab key press is
really working:)