コード例 #1
0
ファイル: test_event.py プロジェクト: yoer77/psychopy
    def test_mouse_clock(self):
        x, y = 0, 0
        scroll_x, scroll_y = 1, 1
        dx, dy = 1, 1
        zeros = [0, 0, 0]
        for b in [
                pyglet.window.mouse.LEFT, pyglet.window.mouse.MIDDLE,
                pyglet.window.mouse.RIGHT
        ]:
            event.mouseButtons = copy.copy(zeros)
            event.mouseTimes = copy.copy(zeros)
            event._onPygletMousePress(x, y, b, None)
            assert event.mouseButtons != zeros
            assert event.mouseTimes != zeros
            event._onPygletMouseRelease(x, y, b, None)
            assert event.mouseButtons == zeros
        event._onPygletMouseWheel(x, y, scroll_x, scroll_y)
        event._onPygletMouseMotion(x, y, dx, dy)
        event.startMoveClock()
        event.stopMoveClock()
        event.resetMoveClock()

        m = event.Mouse()
        assert m.mouseMoveTime() >= 0
        t = 0.05
        core.wait(t)
        assert t - 0.01 < m.mouseMoveTime() < t + 0.01
コード例 #2
0
    def onMouseMove(self, *args, **kwargs):
        """Event handler for mouse move events."""
        # don't process mouse events until ready
        mouseEventHandler = mouse.Mouse.getInstance()
        if mouseEventHandler is None:
            event._onPygletMouseMotion(*args, **kwargs)
            return

        x, y, _, _ = args
        absTime = core.getTime()
        absPos = self._windowCoordsToPix((x, y))
        mouseEventHandler.win = self.win
        mouseEventHandler.setMouseMotionState(absPos, absTime)
コード例 #3
0
ファイル: test_event.py プロジェクト: PieterMoors/psychopy
 def test_mouse_clock(self):
     x, y = 0, 0
     scroll_x, scroll_y = 1, 1
     dx, dy = 1, 1
     zeros = [0, 0, 0]
     for b in [pyglet.window.mouse.LEFT, pyglet.window.mouse.MIDDLE, pyglet.window.mouse.RIGHT]:
         event.mouseButtons = copy.copy(zeros)
         event.mouseTimes = copy.copy(zeros)
         event._onPygletMousePress(x,y, b, None)
         assert event.mouseButtons != zeros
         assert event.mouseTimes != zeros
         event._onPygletMouseRelease(x,y, b, None)
         assert event.mouseButtons == zeros
     event._onPygletMouseWheel(x,y,scroll_x, scroll_y)
     event._onPygletMouseMotion(x, y, dx, dy)
     event.startMoveClock()
     event.stopMoveClock()
     event.resetMoveClock()