Bind Key Event globally in a Frame

Hi!

In Delphi I can set KeyPreview property.

If it is True then the Frame catch the key event first, and if the messages are not handled by the procedure, the frame continue with the normal message handling.

It is a good possibility to catch all key event without Bind to all element in the form.

I need it, because in my frame I wanna use a special key combination and I don’t wanna Bind it to all subcomponents (panels, notebook, images, etc.).

How to do this?

Thanks for your help:
dd

I think what you want is an accelerator table.

If you add the following code to your frame, than you can catch a keystroke (in this case, Ctrl-L), and bind it to an event handler without needing to bind it to any of the subcomponents.

Hope that helps.

···

EVT_TEST_ID = wx.NewId()

wx.EVT_MENU(self, EVT_TEST_ID, self.OnTestEvent)

aTable = wx.AcceleratorTable([

(wx.ACCEL_CTRL, ord('L'), EVT_TEST_ID)

])

self.SetAcceleratorTable(aTable)