##// END OF EJS Templates
Fixed bug in ConsoleWidget where text could be dragged and dropped.
epatters -
Show More
@@ -11,6 +11,27 b' from ansi_code_processor import QtAnsiCodeProcessor'
11 11 from completion_widget import CompletionWidget
12 12
13 13
14 class ConsolePlainTextEdit(QtGui.QPlainTextEdit):
15 """ A QPlainTextEdit suitable for use with ConsoleWidget.
16 """
17 # Prevents text from being moved by drag and drop. Note that is not, for
18 # some reason, sufficient to catch drag events in the ConsoleWidget's
19 # event filter.
20 def dragEnterEvent(self, event): pass
21 def dragLeaveEvent(self, event): pass
22 def dragMoveEvent(self, event): pass
23 def dropEvent(self, event): pass
24
25 class ConsoleTextEdit(QtGui.QTextEdit):
26 """ A QTextEdit suitable for use with ConsoleWidget.
27 """
28 # See above.
29 def dragEnterEvent(self, event): pass
30 def dragLeaveEvent(self, event): pass
31 def dragMoveEvent(self, event): pass
32 def dropEvent(self, event): pass
33
34
14 35 class ConsoleWidget(QtGui.QWidget):
15 36 """ An abstract base class for console-type widgets. This class has
16 37 functionality for:
@@ -161,16 +182,10 b' class ConsoleWidget(QtGui.QWidget):'
161 182 event.accept()
162 183 return False
163 184
164 elif obj == self._control:
165 # Disable moving text by drag and drop.
166 if etype == QtCore.QEvent.DragMove:
167 return True
168
169 185 elif etype == QtCore.QEvent.KeyPress:
186 if obj == self._control:
170 187 return self._event_filter_console_keypress(event)
171
172 188 elif obj == self._page_control:
173 if etype == QtCore.QEvent.KeyPress:
174 189 return self._event_filter_page_keypress(event)
175 190
176 191 return super(ConsoleWidget, self).eventFilter(obj, event)
@@ -546,9 +561,9 b' class ConsoleWidget(QtGui.QWidget):'
546 561 """ Creates and connects the underlying text widget.
547 562 """
548 563 if kind == 'plain':
549 control = QtGui.QPlainTextEdit()
564 control = ConsolePlainTextEdit()
550 565 elif kind == 'rich':
551 control = QtGui.QTextEdit()
566 control = ConsoleTextEdit()
552 567 control.setAcceptRichText(False)
553 568 else:
554 569 raise ValueError("Kind %s unknown." % repr(kind))
@@ -566,7 +581,7 b' class ConsoleWidget(QtGui.QWidget):'
566 581 def _create_page_control(self):
567 582 """ Creates and connects the underlying paging widget.
568 583 """
569 control = QtGui.QPlainTextEdit()
584 control = ConsolePlainTextEdit()
570 585 control.installEventFilter(self)
571 586 control.setReadOnly(True)
572 587 control.setUndoRedoEnabled(False)
General Comments 0
You need to be logged in to leave comments. Login now