support mousewheel in WxPandaWindow, bugfix provided by Craig (LP bug 1210850)

This commit is contained in:
rdb 2013-08-13 14:18:02 +00:00
parent 2274f2e651
commit 1cfa19d473

View File

@ -192,6 +192,7 @@ else:
self.Bind(wx.EVT_RIGHT_DOWN, lambda event: self.__buttonDown(MouseButton.three()))
self.Bind(wx.EVT_RIGHT_UP, lambda event: self.__buttonUp(MouseButton.three()))
self.Bind(wx.EVT_MOTION, self.__mouseMotion)
self.Bind(wx.EVT_MOUSEWHEEL, self.__mouseWheel)
self.Bind(wx.EVT_LEAVE_WINDOW, self.__mouseLeaveWindow)
self.Bind(wx.EVT_KEY_DOWN, self.__keyDown)
self.Bind(wx.EVT_KEY_UP, self.__keyUp)
@ -233,6 +234,15 @@ else:
def __mouseMotion(self, event):
self.inputDevice.setPointerInWindow(*event.GetPosition())
def __mouseWheel(self, event):
amount = event.GetWheelRotation()
if amount > 0.0:
self.inputDevice.buttonDown(MouseButton.wheelUp())
self.inputDevice.buttonUp(MouseButton.wheelUp())
elif amount < 0.0:
self.inputDevice.buttonDown(MouseButton.wheelDown())
self.inputDevice.buttonUp(MouseButton.wheelDown())
def __mouseLeaveWindow(self, event):
self.inputDevice.setPointerOutOfWindow()