def event(self, event):
     retVal = HistoryBase.event(self, event)
     if event.type() == QEvent.KeyPress and self.isQueryKey(event):
         self.returnPressed.emit()
         return True
     if not retVal:
         if self._triggerOnEnter and \
            event.type() == QEvent.KeyPress and \
            event.key() == Qt.Key_Return and \
            ((int(event.modifiers()) & Qt.AltModifier) == Qt.AltModifier or \
             (int(event.modifiers()) & Qt.ShiftModifier) == Qt.ShiftModifier):
             event = QKeyEvent(QEvent.KeyPress, Qt.Key_Return, Qt.NoModifier, event.text(), event.isAutoRepeat(), event.count())
         return super(HistoryTextEdit, self).event(event)
     return True
Esempio n. 2
0
    def notify(self, receiver, event):
        if event.type() == QEvent.KeyPress:
            key_event = QKeyEvent(event)
            key_text = PyQt4.QtGui.QKeySequence(key_event.key() | key_event.modifiers().__int__()).toString()
            text = key_event.text()

            if (key_text, text) == KEY_STOP_RECORDING and not self.recording:
                self.reproduce_keys(self._keys_recorded)
            elif (key_text, text) == KEY_STOP_RECORDING and self.recording:
                self.recording = False
            elif self.recording:
                self._keys_recorded.append((key_text, unicode(text)))

            if (key_text, text) == KEY_START_RECORDING:
                self.recording = True
                self._keys_recorded = []

            # ==============================================================================
            #             key = {
            #                 "key": key_event.key(),
            #                 "modifiers": int(key_event.modifiers()),
            #                 "text": key_event.text(),
            #                 "autorepeat": key_event.isAutoRepeat(),
            #                 "autorepeat": key_event.isAutoRepeat(),
            #                 "count": key_event.count()
            #             }
            #             print key
            # ==============================================================================
            # ==============================================================================
            #         if event.type() == QEvent.KeyPress:
            #             key_event = QKeyEvent(event)
            #             ker = QKeyEvent(QEvent.KeyPress,
            #                             key_event.key(),
            #                             key_event.modifiers(),
            #                             key_event.text(),
            #                             key_event.isAutoRepeat(),
            #                             key_event.count())
            #             super(MiowApplication, self).notify(receiver, ker)
            # ==============================================================================
            for key_as_text, method in self.keys_map:
                if key_as_text == (key_text, text):
                    replace = method(key_event, key_as_text)
                    if replace == None:
                        return True
                    elif replace == False:
                        return super(MiowApplication, self).notify(receiver, event)
                    else:
                        return self.notify(receiver, replace)

        return super(MiowApplication, self).notify(receiver, event)
    def keyPressEvent(self, keyEvent: QtGui.QKeyEvent):
        """
        Undo safe wrapper for the native ``keyPressEvent`` method.

        |Args|

        * ``keyEvent`` (**QKeyEvent**): the key event to process.

        |Returns|

        **None**

        |Raises|

        * **QtmacsArgumentError** if at least one argument has an invalid type.
        """
        undoObj = UndoInsert(self, keyEvent.text())
        self.qteUndoStack.push(undoObj)
Esempio n. 4
0
    def keyPressEvent(self, event):
        key = event.key()
        modifier = event.modifiers()
        numChars = len(self.toPlainText())
        
        if key in [Qt.Key_Return, Qt.Key_Enter]:
            if modifier == Qt.ShiftModifier:
                event = QKeyEvent(event.type(), Qt.Key_Return, Qt.NoModifier, event.text())
            else:
                self.enviarTexto()
                return

        #Atualizando o texto do Edit
        QTextEdit.keyPressEvent(self, event)
        
        if numChars > 0 and len(self.toPlainText()) == 0:
            self._modificarSituacao(EditEnviar.APAGANDO)
            QTimer.singleShot(2000, lambda: self._analisarSituacao())
        elif numChars == 0 and len(self.toPlainText()) > 0:
            self._modificarSituacao(EditEnviar.DIGITANDO)