Пример #1
0
 def mouseReleaseEvent(self, event):
     if self.show_cursor_until is None:
         # Ignore clicks when cursor is hidden
         return
     InputHandler.add_event(Event.create_mouse_event(
         event, (self.width(), self.height())))
     self.ensure_cursor_visible()
Пример #2
0
    def keyPressEvent(self, event):
        def modifier():
            if macosx:
                # This should correspond to the Cmd key(s) on OS X
                return int(event.modifiers()) & Qt.ControlModifier
            else:
                return int(event.modifiers()) & Qt.AltModifier

        assert isinstance(event, QKeyEvent)
        # print(event.isAutoRepeat(), event.type())
        if event.isAutoRepeat():
            return
        if modifier():
            if event.key() == Qt.Key_Return:
                self.window().set_fullscreen(not self.window().is_fullscreen())
                return
            if event.key() == Qt.Key_Q:
                self.window().close()
                return

        InputHandler.add_event(Event.create_key_event(event))
        text = event.text()
        if text and text in TEXT_WHITE_LIST:
            # We don't want special characters such as return, backspace
            # and escape (etc) to be sent as text events. For now, we use
            # a simple white list.
            InputHandler.add_event({"type": "text", "text": event.text()})
Пример #3
0
 def mouseReleaseEvent(self, event):
     if self.show_cursor_until is None:
         # Ignore clicks when cursor is hidden
         return
     InputHandler.add_event(
         Event.create_mouse_event(event, (self.width(), self.height())))
     self.ensure_cursor_visible()
Пример #4
0
 def mouseMoveEvent(self, event):
     if self.first_motion_event:
         # Ignore initial motion event, so the cursor is not visible
         # at startup.
         self.first_motion_event = False
         return
     InputHandler.add_event(Event.create_mouse_event(
         event, (self.width(), self.height())))
     self.ensure_cursor_visible()
Пример #5
0
 def mouseMoveEvent(self, event):
     if self.first_motion_event:
         # Ignore initial motion event, so the cursor is not visible
         # at startup.
         self.first_motion_event = False
         return
     InputHandler.add_event(
         Event.create_mouse_event(event, (self.width(), self.height())))
     self.ensure_cursor_visible()
Пример #6
0
 def set_blank_cursor(self, blank=True):
     if blank:
         cursor = Qt.BlankCursor
     else:
         cursor = Qt.ArrowCursor
     self.setCursor(cursor)
     if self.gl_widget is not None:
         self.gl_widget.setCursor(cursor)
     if blank:
         # Fool app to think mouse has moved to neutral position,
         # in order to "de-focus" focused item.
         InputHandler.add_event(Event.create_fake_mouse_event(
             "mouse-motion", 960, 540, (self.width(), self.height())))
Пример #7
0
 def set_blank_cursor(self, blank=True):
     if blank:
         cursor = Qt.BlankCursor
     else:
         cursor = Qt.ArrowCursor
     self.setCursor(cursor)
     if self.gl_widget is not None:
         self.gl_widget.setCursor(cursor)
     if blank:
         # Fool app to think mouse has moved to neutral position,
         # in order to "de-focus" focused item.
         InputHandler.add_event(
             Event.create_fake_mouse_event("mouse-motion", 960, 540,
                                           (self.width(), self.height())))
Пример #8
0
 def keyReleaseEvent(self, event):
     assert isinstance(event, QKeyEvent)
     # print(QKeyEvent, event.isAutoRepeat(), event.type())
     if event.isAutoRepeat():
         return
     InputHandler.add_event(Event.create_key_event(event))