Newbie question: Keyboard input problem

Hi,

I have a main window that I’d like to have intercept all keyboard input, and then Skip() on if it doesn’t have a given key combination registered. I tried using:

    self.Bind(wx.EVT_KEY_DOWN, self.OnChar)

I also tried:

    wx.EVT_CHAR(self, self.OnChar)

but that didn’t capture any keypresses (apparently because a frame can’t receive keyboard input). Then I tried

    self.panel.Bind(wx.EVT_KEY_DOWN, self.OnChar)
    ...
    self.panel.SetFocus()

where panel was an arbitrarily attached wx.Panel that was made to receive focus when the window was created. This worked, sort of - so long as no child widget got focus, everything proceeded as expected (for now, self.OnChar() is just a simple handler to tell me what keys were pressed). So, the question: Is there any way to create a set of hotkeys that works for an entire window, whether the panel or another child control has the focus, that can capture certain hotkeys that are registered with it and pass others on to the child controls (I should add that I’m working in Linux, but am making an app that should be cross-platform)? This was pretty straightforward in pygtk.

Thanks,
Seth

Hello,

See: AcceleratorTable

http://wxpython.org/docs/api/wx.AcceleratorTable-class.html

···

On Jan 1, 2009, at 3:53 PM, Seth Mahoney wrote:

Hi,

I have a main window that I'd like to have intercept all keyboard input, and then Skip() on if it doesn't have a given key combination registered. I tried using:

        self.Bind(wx.EVT_KEY_DOWN, self.OnChar)

I also tried:

        wx.EVT_CHAR(self, self.OnChar)

but that didn't capture any keypresses (apparently because a frame can't receive keyboard input). Then I tried

        self.panel.Bind(wx.EVT_KEY_DOWN, self.OnChar)
        ...
        self.panel.SetFocus()

where panel was an arbitrarily attached wx.Panel that was made to receive focus when the window was created. This worked, sort of - so long as no child widget got focus, everything proceeded as expected (for now, self.OnChar() is just a simple handler to tell me what keys were pressed). So, the question: Is there any way to create a set of hotkeys that works for an entire window, whether the panel or another child control has the focus, that can capture certain hotkeys that are registered with it and pass others on to the child controls (I should add that I'm working in Linux, but am making an app that should be cross-platform)? This was pretty straightforward in pygtk.

Thanks,
Seth
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users