I can bind an event to a textctrl box np. The problem is I have to be clicked inside of the textctrl box to "catch" this event. I am hoping to be able to catch anytime someone presses the Arrow keys while the main window has focus.
NOT WORKING:
wx.EVT_KEY_DOWN(self, self.OnKeyDown)
WORKING:
self.NudgeTxt = wx.TextCtrl(self.panel, size=(40,20), value=str(5))
wx.EVT_KEY_DOWN(self.NudgeTxt, self.OnKeyDown)
I am pretty sure I am missing something easy. However am a bit stuck.
Instead try binding to wx.EVT_CHAR_HOOK
e.g..
self.Bind(wx.EVT_CHAR_HOOK, self.onKey)
...
def onKey(self, evt):
if evt.GetKeyCode() == wx.WXK_DOWN:
print "Down key pressed"
else:
evt.Skip()