def keyPressEvent(self, ev): text = unicode(ev.text()) key = ev.key() action = self.key_dispatcher.get(key, None) if callable(action): action() elif key in (Qt.Key_Escape,): QTextEdit.keyPressEvent(self, ev) elif text: self.text_typed(text) else: QTextEdit.keyPressEvent(self, ev)
def keyPressEvent(self, event): """ Overrides the superclass method. """ #If user hits 'Enter' key (return key), don't do anything. if event.key() == Qt.Key_Return: #there is no obvious way to allow only a single line in a #QTextEdit (we can use some methods that restrict the columnt width #, line wrapping etc but this is untested when the line contains # huge umber of characters. Anyway, the following always works #and fixes bug 2713 if not self._permit_enter_keystroke: return QTextEdit.keyPressEvent(self, event)