Add in a default implementation of the event() override

This commit is contained in:
Kovid Goyal 2014-01-18 11:15:17 +05:30
parent 84ae3b8595
commit 081836db66

View File

@ -55,9 +55,7 @@ class LineNumbers(QWidget): # {{{
class PlainTextEdit(QPlainTextEdit):
''' A class that overrides some methods from QPlainTextEdit to fix handling
of the nbsp unicode character. In addition to this you also have to
override the default copy/cut actions triggered by the keyboard shortcuts.
See the event() method of the TextEdit class for example. '''
of the nbsp unicode character. '''
def __init__(self, parent=None):
QPlainTextEdit.__init__(self, parent)
@ -97,6 +95,13 @@ class PlainTextEdit(QPlainTextEdit):
md.setText(self.selected_text)
clipboard.setMimeData(md, clipboard.Selection)
def event(self, ev):
if ev.type() == ev.ShortcutOverride and ev in (QKeySequence.Copy, QKeySequence.Cut):
ev.accept()
(self.copy if ev == QKeySequence.Copy else self.cut)()
return True
return QPlainTextEdit.event(self, ev)
class TextEdit(PlainTextEdit):
def __init__(self, parent=None):