def keyPressEvent(self, event): if event.key() == Qt.Key_Up: cursor = self.textCursor() position = cursor.position() if position == 0 and not cursor.hasSelection(): # The cursor is at the beginning of the line. # If we have selection then simply reset the cursor. # Otherwise, emit a signal so that the parent can # change focus. self.emit(SIGNAL('leave()')) return HintedTextView.keyPressEvent(self, event)
def keyPressEvent(self, event): if event.key() == Qt.Key_Up: cursor = self.textCursor() position = cursor.position() if position == 0 and not cursor.hasSelection(): # The cursor is at the beginning of the line. # If we have selection then simply reset the cursor. # Otherwise, emit a signal so that the parent can # change focus. self.emit(SIGNAL('leave()')) return HintedTextView.keyPressEvent(self, event)
def keyPressEvent(self, event): if event.key() == Qt.Key_Up: cursor = self.textCursor() position = cursor.position() if position == 0 and not cursor.hasSelection(): # The cursor is at the beginning of the line. # If we have selection then simply reset the cursor. # Otherwise, emit a signal so that the parent can # change focus. self.emit(SIGNAL('leave()')) elif self.value()[:position].count('\n') == 0: cursor.movePosition(QtGui.QTextCursor.StartOfLine) self.setTextCursor(cursor) return HintedTextView.keyPressEvent(self, event)
def keyPressEvent(self, event): if event.key() == Qt.Key_Up: cursor = self.textCursor() position = cursor.position() if position == 0 and not cursor.hasSelection(): # The cursor is at the beginning of the line. # If we have selection then simply reset the cursor. # Otherwise, emit a signal so that the parent can # change focus. self.emit(SIGNAL('leave()')) elif self.value()[:position].count('\n') == 0: cursor.movePosition(QtGui.QTextCursor.StartOfLine) self.setTextCursor(cursor) return HintedTextView.keyPressEvent(self, event)