How would I use the 'wxTE_PROCESS_TAB' style for a wxTextCtrl to tab to an adjacent text control when the TAB key is pressed ?
Pete
How would I use the 'wxTE_PROCESS_TAB' style for a wxTextCtrl to tab to an adjacent text control when the TAB key is pressed ?
Pete
The ordinary behavior of a wxTextCtrl is for the TAB key to pass
focus to the next control in the dialog's tab traversal list. In
other words, EVT_CHAR does not ordinarily process TAB key presses.
If the wxTE_PROCESS_TAB style is used, however, the TAB key can be
captured by EVT_CHAR. In this case, Enter and Ctrl-Enter will still
pass focus to the next control.
In the following example, the middle text control captures the TAB
key presses while the first and third do not.
--- Peter Moscatt <pmoscatt@bigpond.net.au> wrote:
How would I use the 'wxTE_PROCESS_TAB' style for a wxTextCtrl to
tab to an adjacent text control when the TAB key is pressed ?
#############################################################
from wxPython.wx import *
class MyFrame(wxFrame):
def __init__(self, parent=None, id=-1, title='Process Tab'):
wxFrame.__init__(self, parent, id, title)
panel = wxPanel(self, -1)
t1 = wxTextCtrl(panel, 10, '')
t2 = wxTextCtrl(panel, 20, '',
wxDefaultPosition,
wxDefaultSize,
wxTE_PROCESS_TAB)
t3 = wxTextCtrl(panel, 30, '')
EVT_CHAR(t1, self.OnChar)
EVT_CHAR(t2, self.OnChar)
EVT_CHAR(t3, self.OnChar)
# the rest of this is to control the frame layout
box0 = wxBoxSizer(wxVERTICAL)
box0.Add(t1, 0, wxEXPAND)
box0.Add(t2, 0, wxEXPAND)
box0.Add(t3, 0, wxEXPAND)
panel.SetSizer(box0)
panel.Layout()
panel.SetAutoLayout(true)
box0.Fit(self)
box0.SetSizeHints(self)
def OnChar(self, event):
print 'EvtChar: %d\n' % event.GetKeyCode()
if event.GetKeyCode() != 9:
event.Skip()
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame()
frame.Show(true)
self.SetTopWindow(frame)
return true
app = MyApp(0)
app.MainLoop()
=====
Donnal Walter
Arkansas Children's Hospital
__________________________________________________
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information
http://dailynews.yahoo.com/fc/US/Emergency_Information/
As long as the control is on a wxPanel or a wxDialog.
--- Peter Moscatt <pmoscatt@bigpond.net.au> wrote:
> How would I use the 'wxTE_PROCESS_TAB' style for a wxTextCtrl to
> tab to an adjacent text control when the TAB key is pressed ?The ordinary behavior of a wxTextCtrl is for the TAB key to pass
focus to the next control in the dialog's tab traversal list.
--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!