Parent panel cannot gain focus (To handle key events) Topic is solved

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
grashopa
Earned a small fee
Earned a small fee
Posts: 19
Joined: Thu Nov 10, 2005 6:08 am

Parent panel cannot gain focus (To handle key events)

Post by grashopa » Tue Feb 19, 2008 3:51 am

I want the parent panel to receive KeyEvents. I figured the simplest way would be to redirect the childrens focus to the parent panel. However it appears the parent panel cannot receive focus. As wxPanel.SetFocus does nothing below.

This works fine if I SetFocus onto a child control. But I dont want child controls controling each other and the panel layout may change and should still work..

MSW, wxPython, wxPanel class

Code: Select all

        for c in self.GetChildren():
            c.Bind(wx.EVT_SET_FOCUS,self.KillChildFocus,c)
        
    def KillChildFocus(self,event):
        self.SetFocus()

clyde729
Super wx Problem Solver
Super wx Problem Solver
Posts: 426
Joined: Mon May 29, 2006 10:50 pm
Location: Jena, Germany

Post by clyde729 » Tue Feb 19, 2008 6:55 am

OS: Windows XP Home, Compiler: MingW, Version: wxWidgets 2.8.0, IDE: wx-Devcpp

grashopa
Earned a small fee
Earned a small fee
Posts: 19
Joined: Thu Nov 10, 2005 6:08 am

Post by grashopa » Tue Feb 19, 2008 9:42 am

Booyah!

Post Reply