diff options
author | mae <qt-info@nokia.com> | 2009-10-05 13:07:10 (GMT) |
---|---|---|
committer | mae <qt-info@nokia.com> | 2009-10-05 13:12:19 (GMT) |
commit | 6ce698050bbe9a4ec5198f1e08b94d51b8a6c9bd (patch) | |
tree | 8766eb898d27b4ac65d1a9367f596d242d8987c9 /src/gui/text/qtextcontrol.cpp | |
parent | bfe0e5c0d47780542b174dc96973920fba11c451 (diff) | |
download | Qt-6ce698050bbe9a4ec5198f1e08b94d51b8a6c9bd.zip Qt-6ce698050bbe9a4ec5198f1e08b94d51b8a6c9bd.tar.gz Qt-6ce698050bbe9a4ec5198f1e08b94d51b8a6c9bd.tar.bz2 |
Fix QKeySequence::DeleteEndOfWord and QKeySequence::DeleteStartOfWord
QTextControl showed inconsistent behaviour with DeleteEndOfWord and
DeleteStartOfWord when the cursor had a selection. With this patch,
the commands will simply delete the existing selection, which is
consistent behaviour with in other IDEs.
Reviewed-by: Simon Hausmann
Diffstat (limited to 'src/gui/text/qtextcontrol.cpp')
-rw-r--r-- | src/gui/text/qtextcontrol.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 6def06e..db4c07c 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -1223,11 +1223,13 @@ void QTextControlPrivate::keyPressEvent(QKeyEvent *e) cursor.deleteChar(); } else if (e == QKeySequence::DeleteEndOfWord) { - cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor); + if (!cursor.hasSelection()) + cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor); cursor.removeSelectedText(); } else if (e == QKeySequence::DeleteStartOfWord) { - cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor); + if (!cursor.hasSelection()) + cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor); cursor.removeSelectedText(); } else if (e == QKeySequence::DeleteEndOfLine) { |