Tab one control

I have a splitter window, containing a listctrl at the top and a panel with multiple controls at the bottom.

In the listctrl.OnItemSelected I fill the controls on the panel below.

I would then like the focus to be on the first control of the panel and based on other messages in the archive I call the following function as the last thing in listctrl.OnItemSelected.

def TabOneControl(self):
        test = wxNavigationKeyEvent()
        test.SetDirection(WXK_TAB)
        test.SetWindowChange(0)
        test.SetEventObject(self)
        self.GetEventHandler().ProcessEvent(test)
        del test

This is tabbing to the control I like to tab to, BUT the focus is set "back" to the item selected on the listctrl by "someone/thing". Can anyone explain what is happening and/or how to make this do what I like to do.

BTW, if I set "SetWindowChange(1) then it changes notebook pages.

Is there any documentation form wxNavigationKeyEvent?

Thanks and best regards
Werner

Hi Robin,

The wxCallAfter does the trick - Great!

Tried it before but couldn't get it to work, as I always included the ().

Thanks a lot
Werner

Robin Dunn wrote:

···

Werner F. Bruhin wrote:

I have a splitter window, containing a listctrl at the top and a panel with multiple controls at the bottom.

In the listctrl.OnItemSelected I fill the controls on the panel below.

I would then like the focus to be on the first control of the panel and based on other messages in the archive I call the following function as the last thing in listctrl.OnItemSelected.

def TabOneControl(self):
       test = wxNavigationKeyEvent()
       test.SetDirection(WXK_TAB)
       test.SetWindowChange(0)
       test.SetEventObject(self)
       self.GetEventHandler().ProcessEvent(test)
       del test

Why not just:

    child = thePanel.GetChildren()[0]
    child.SetFocus()

This is tabbing to the control I like to tab to, BUT the focus is set "back" to the item selected on the listctrl by "someone/thing".

or maybe this if it still resets the focus to the listctrl:

    child = thePanel.GetChildren()[0]
    wxCallAfter(child.SetFocus)