From: John L. <jla...@gm...> - 2012-06-19 20:17:27
|
On Tue, Jun 19, 2012 at 2:11 PM, Milind Gupta <mil...@gm...> wrote: > Hi, > I am trying to associate key events with a frame but it doesn't seem > to be working. I am doing this: > > frame:Connect(ID_FRAME, wx.wxEVT_CHAR, CharKeyEvent) You probably can't focus the frame if you have a window as a child for the frame since it always gets the focus since it fills the client area by default so it'd be hard to click on it or at least I couldn't do it in MSW. Secondly, you need to either use the window style wxWANTS_CHARS for wxEVT_CHAR to work or use wxEVT_CHAR_HOOK which is sent before wxWidgets does any key handling, just be sure to call event:Skip(true) if you want the wxKeyEvent handled normally. > I looked at the grid.wx.lua example also, how does the key combinations > caught to call the menu event handlers? When you create a menu item; "&Open...\tCtrl+O", wxWidgets will add an accelerator to intercept Ctrl+O and send the menu event and you won't get a wxEVT_CHAR for it. Note that wxEVT_CHAR_HOOK will be sent though. Regards, John |