0
votes

I'm making a firstperson/camera view using wxPython and an OpenGL pane, and I want to use mouse motion to control the camera angle. To do this I need the mouse movement in x,y per frame.

The way I would do it in other environments would be to move the cursor to the screen centre at the end of each frame, after the movement data has been grabbed - that way it'll never move far away from the center and out of the window bounds.

I found wx.WarpPointer(x,y), which does what I want - except it also sends EVT_MOTION which is, as far as I can tell, identical to real mouse motion. So it just moves the view right back to wherever it started.

Is there some way to differentiate between WarpPointer and user-input mouse events? Or some way to cleverly bind to different functions and StopPropagation on WarpPointer before it can effect this frame's mouse movement?

Alternately, is there another way to do this in wxPython? CaptureMouse seemed good but it just locks the pointer within the window instead of the screen bounds.

1

1 Answers

0
votes

Set a flag just before calling WarpPointer and in your EVT_MOTION handler check the flag and proceed accordingly and reset the flag.

def SomeMethod(self):
    self.isWarping = True
    wx.WarpPointer(x, y)

def OnMotion(self, evt):
    if self.isWarping:
        self.isWarping = False
        do something
    else:
        do something else