Allow Ctrl+Del to be propagated to the document editor

This commit is contained in:
Veronica K. B. Olsen
2021-02-11 19:11:41 +01:00
parent 3a60abaeee
commit 08651685d4
3 changed files with 17 additions and 3 deletions
+5 -2
View File
@@ -37,11 +37,11 @@ from time import time
from PyQt5.QtCore import (
Qt, QSize, QTimer, pyqtSlot, pyqtSignal, QRegExp, QRegularExpression,
QPointF, QObject, QRunnable, QPropertyAnimation
QPointF, QObject, QRunnable, QPropertyAnimation, QEvent
)
from PyQt5.QtGui import (
QTextCursor, QTextOption, QKeySequence, QFont, QColor, QPalette,
QTextDocument, QCursor, QPixmap
QTextDocument, QCursor, QPixmap, QKeyEvent
)
from PyQt5.QtWidgets import (
qApp, QTextEdit, QAction, QMenu, QShortcut, QMessageBox, QWidget, QLabel,
@@ -719,6 +719,8 @@ class GuiDocEditor(QTextEdit):
self._replaceQuotes("'", self.typSQOpen, self.typSQClose)
elif theAction == nwDocAction.REPL_DBL:
self._replaceQuotes("\"", self.typDQOpen, self.typDQClose)
elif theAction == nwDocAction.DEL_WORD:
self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_Delete, Qt.ControlModifier))
else:
logger.debug("Unknown or unsupported document action %s" % str(theAction))
self._allowAutoReplace(True)
@@ -843,6 +845,7 @@ class GuiDocEditor(QTextEdit):
* The undo/redo/select all sequences bypasses the docAction
pathway from the menu, so we redirect them back from here.
"""
print(keyEvent.type())
self.lastActive = time()
isReturn = keyEvent.key() == Qt.Key_Return
isReturn |= keyEvent.key() == Qt.Key_Enter