Hi all,
In the following code, I'm trying to bind a hotkey that is local to my
application's main window and its child controls. In other words, if
the application doesn't have focus, the hotkey should be passed to
Windows as normal. That's the bit that's puzzling me. I'm using
Event.Skip() in my event handler, and if my application isn't focussed
the action associated with the hotkey doesn't occur. However, nor does
the keypress get passed to other applications.
class HotkeyFrame(wx.Frame):
def __init__(self, *args, **kwargs):
super(HotkeyFrame, self).__init__(parent=None, title='Hotkey
Frame', *args, **kwargs)
VK_F1 = 0x70
hotkey_id = wx.NewId()
self.Bind(wx.EVT_HOTKEY, self.onHotkeyPressed, id=hotkey_id)
self.RegisterHotKey(hotkey_id, 0, VK_F1)
def onHotkeyPressed(self, event):
focus = self.FindFocus()
if self.IsDescendant(focus):
wx.Bell()
else:
event.Skip()
app = wx.App()
frame = HotkeyFrame()
frame.Show()
app.MainLoop()
···
--
James Scholes
http://twitter.com/JamesScholes