From 188d0ca744a9567809ce06e3641f0e99c77eb027 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Sat, 13 Jun 2015 17:05:29 -0500 Subject: [PATCH] Editor: Use our own copy method for Ctrl+C to avoid Qt copying in HTML Fixes #2285 --- spyderlib/widgets/sourcecode/base.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spyderlib/widgets/sourcecode/base.py b/spyderlib/widgets/sourcecode/base.py index 77dd8fd0b78..4112ac2117a 100644 --- a/spyderlib/widgets/sourcecode/base.py +++ b/spyderlib/widgets/sourcecode/base.py @@ -460,6 +460,17 @@ def toPlainText(self): else: return super(TextEditBaseWidget, self).toPlainText() + def keyPressEvent(self, event): + text, key = event.text(), event.key() + ctrl = event.modifiers() & Qt.ControlModifier + meta = event.modifiers() & Qt.MetaModifier + # Use our own copy method for {Ctrl,Cmd}+C to avoid Qt + # copying text in HTML (See Issue 2285) + if (ctrl or meta) and key == Qt.Key_C: + self.copy() + else: + super(TextEditBaseWidget, self).keyPressEvent(event) + #------Text: get, set, ... def get_selection_as_executable_code(self): """Return selected text as a processed text,