Event key down and cursor keys

Adi Sieker wrote:

Adi Sieker wrote:

Hi,

using wx.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) in a Class dervied from wx.PyControl doesn't seem to work for the cursor keys.
Which event do I need to bind to to also get the cursor keys?

To follow up to my own mail.
Including wx.WANTS_CHARS in the style Parameter
will call my event handler for the cursor keys, but
it also calls my event handler for the TAB key which
breaks tab traversal.

The next question is:
How do I know which control to focus on tab navigation.
Calling event.Skip() doesn't help.

Generate and send a wx.NavigationKeyEvent when you get a Tab or a Shift-Tab. Something like this:

  if evt.GetKeyCode() == wx.WXK_TAB:
    forward = not evt.ShiftDown()
    ne = wx.NavigationKeyEvent()
    ne.SetDirection(forward)
    ne.SetCurrentFocus(self)
    ne.SetEventObject(self)
    self.GetEventHandler().ProcessEvent(ne)

ยทยทยท

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi Robin,

Robin Dunn wrote:

Generate and send a wx.NavigationKeyEvent when you get a Tab or a Shift-Tab. Something like this:

    if evt.GetKeyCode() == wx.WXK_TAB:
        forward = not evt.ShiftDown()
        ne = wx.NavigationKeyEvent()
        ne.SetDirection(forward)
        ne.SetCurrentFocus(self)
        ne.SetEventObject(self)
        self.GetEventHandler().ProcessEvent(ne)

that nearly did the trick.
I had to change the last line to:
self.GetParent().GetEventHandler().ProcessEvent(ne)

Can I safley assume that a PyControl dervied Control
will always have a parent?

Tschau
    Adi