[wxruby-users] Focus on TextCtrl
Alex Fenton
alex at pressure.to
Mon Jan 14 04:51:26 EST 2008
Hi
Anton Komarov 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
More information about the wxruby-users
mailing list