# Tab key traversal

**URL:** <https://www.ruby-forum.com/t/tab-key-traversal/185477>\
**Category:** wxRuby\
**Created:** [March 21, 2010, 1:26am UTC](https://www.ruby-forum.com/t/tab-key-traversal/185477 "2010-03-21T01:26:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pnomolos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/85f322/32.png) [@pnomolos](https://www.ruby-forum.com/u/pnomolos)\
**Post date:** [March 21, 2010, 1:26am UTC](https://www.ruby-forum.com/t/tab-key-traversal/185477/1 "2010-03-21T01:26:13Z")

</div>

Below is my attempt at changing the focus from one text control to the  
next control after a person presses the tab key. The wxTE\_PROCESS\_TAB  
style property has been selected for each of the controls. What  
corrections do I have to make? Thanks.

#!/usr/bin/env ruby  
require ‘rubygems’  
require ‘wx’  
require ‘tp1.rb’

class MainFrame \< TPSC  
def on\_init  
m\_scrolledwindow6.set\_virtual\_size(400, 100)  
m\_scrolledwindow6.set\_scroll\_rate(5, 5)

wxEVT\_CHAR(@m\_textCtrl2) { m\_textCtrl3.set\_focus }  
wxEVT\_CHAR(@m\_textCtrl3) { m\_textCtrl4.set\_focus }  
wxEVT\_CHAR(@m\_textCtrl4) { m\_textCtrl4.set\_focus }

# evt\_button(@m\_buttonincrement) { increaseColour }

# evt\_button(@m\_buttondecrement) { decreaseColour }

end

Wx::App.run do  
self.app\_name = ‘TestNotebook’  
frame = MainFrame.new  
frame.show  
end

---

<div class="post-metadata">

**Author:** ![pnomolos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/85f322/32.png) [@pnomolos](https://www.ruby-forum.com/u/pnomolos)\
**Post date:** [March 22, 2010, 2:52am UTC](https://www.ruby-forum.com/t/tab-key-traversal/185477/2 "2010-03-22T02:52:08Z")

</div>

Sorry, I don’t really understand your question,  
but if I got it right,  
you expect that if you press tab key, then focus will move to next  
control  
to do so automatically, you simply have to put every control  
in a panel. I am personally doing it in this order :  
frame -\> panel -\> sizer -\> control

Hope this help
