2
0
Эх сурвалжийг харах

catch keyboard focus, mouse capture

David Rose 14 жил өмнө
parent
commit
c8e3c72b3a

+ 8 - 0
direct/src/wxwidgets/WxPandaWindow.py

@@ -174,6 +174,7 @@ else:
                 raise StandardError, "Couldn't get an OpenGL pipe."
                 raise StandardError, "Couldn't get an OpenGL pipe."
 
 
             self.win = base.openWindow(callbackWindowDict = callbackWindowDict, pipe = pipe, gsg = gsg, type = 'onscreen')
             self.win = base.openWindow(callbackWindowDict = callbackWindowDict, pipe = pipe, gsg = gsg, type = 'onscreen')
+            self.hasCapture = False
             self.inputDevice = None
             self.inputDevice = None
             if hasattr(self.win, 'getInputDevice'):
             if hasattr(self.win, 'getInputDevice'):
                 self.inputDevice = self.win.getInputDevice(0)
                 self.inputDevice = self.win.getInputDevice(0)
@@ -216,9 +217,16 @@ else:
                 self.win = None
                 self.win = None
 
 
         def __buttonDown(self, button):
         def __buttonDown(self, button):
+            self.SetFocus()
+            if not self.hasCapture:
+                self.CaptureMouse()
+                self.hasCapture = True
             self.inputDevice.buttonDown(button)
             self.inputDevice.buttonDown(button)
 
 
         def __buttonUp(self, button):
         def __buttonUp(self, button):
+            if self.hasCapture:
+                self.ReleaseMouse()
+                self.hasCapture = False
             self.inputDevice.buttonUp(button)
             self.inputDevice.buttonUp(button)
 
 
         def __mouseMotion(self, event):
         def __mouseMotion(self, event):