Hello,
I need to customise what occurs with various key events on my
FloatCanvas. I would like to do this the same way I customise mouse
clicks, via the GUIMode code.
I have included a patch which allows this to occur.
The only caveat is that you have to make sure that the FloatCanvas
itself has the keyboard focus before these events will occur. I have
code in my top level panel to give the Focus to the FloatCanvas, so it
works for me.
Hope this is useful!
Tim 'Mithro' Ansell
diff --git a/extra/wxFloatCanvas/FloatCanvas.py b/extra/wxFloatCanvas/FloatCanvas.py
index 5e4e4b3..0ab7673 100644
--- a/extra/wxFloatCanvas/FloatCanvas.py
+++ b/extra/wxFloatCanvas/FloatCanvas.py
@@ -2209,6 +2209,8 @@ class FloatCanvas(wx.Panel):
wx.EVT_RIGHT_DCLICK(self, self.RightDoubleCLickEvent)
wx.EVT_MOTION(self, self.MotionEvent)
wx.EVT_MOUSEWHEEL(self, self.WheelEvent)
+ wx.EVT_KEY_DOWN(self, self.KeyDownEvent)
+ wx.EVT_KEY_UP(self, self.KeyUpEvent)
## CHB: I'm leaving these out for now.
#wx.EVT_ENTER_WINDOW(self, self. )
@@ -2475,6 +2477,16 @@ class FloatCanvas(wx.Panel):
self.GUIMode.OnRightUp(event)
event.Skip()
+ def KeyDownEvent(self, event):
+ if self.GUIMode and hasattr(self.GUIMode, 'OnKeyDown'):
+ self.GUIMode.OnKeyDown(event)
+ event.Skip()
+
+ def KeyUpEvent(self, event):
+ if self.GUIMode and hasattr(self.GUIMode, 'OnKeyUp'):
+ self.GUIMode.OnKeyUp(event)
+ event.Skip()
+
def MakeNewBuffers(self):
self._BackgroundDirty = True
# Make new offscreen bitmap:
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas