def newLineEditKeyPressEvent(self, evt): if keyMatches(evt, "Ctrl+A"): self.setCursorPosition(0) elif keyMatches(evt, "Ctrl+E"): self.setCursorPosition(len(self.text())) elif keyMatches(evt, "Ctrl+K"): p = self.cursorPosition() l = len(self.text()) self.setSelection(p, l-p+1) self.cut() else: # nothing special return QLineEdit._keyPressEvent(self, evt) return evt.accept()
def keyPressEvent(self, evt): if keyMatches(evt, "Ctrl+Y") or keyMatches(evt, "Ctrl+V"): self.onPaste() elif keyMatches(evt, "Alt+W"): self.onCopy() elif keyMatches(evt, "Ctrl+W") or keyMatches(evt, "Ctrl+X"): self.onCut() elif keyMatches(evt, "Ctrl+A"): self.onStartLine() elif keyMatches(evt, "Ctrl+E"): self.onEndLine() elif keyMatches(evt, "Ctrl+K"): self.onDeleteEndOfLine() # need those here because Qt is stupid elif keyMatches(evt, "Ctrl+C"): self.editor.onClozeSwitch() elif keyMatches(evt, "Ctrl+Shift+C"): self.editor.onClozeInsert() else: # no special code return QWebView.keyPressEvent(self, evt) # we parsed it manually return evt.accept()