Make it easier to select words at the start of a line.
QTextControl's word selection will only include a word if the cursor position is past the mid point of the word. This can make it difficult to select words near the edges of the screen on touch devices. For the TextEdit word selection mode select a word ignore the relative position within a word. Task-number: QT-5206 Change-Id: I4e5675596cd89934b3c2bc5d825088887c222fe8 Reviewed-by: Martin Jones Reviewed-on: http://codereview.qt.nokia.com/4166 Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
This commit is contained in:
parent
06e2ce51d1
commit
bb2f045c10
@ -689,6 +689,15 @@ void QTextControlPrivate::extendWordwiseSelection(int suggestedNewPosition, qrea
|
||||
if (!wordSelectionEnabled && (mouseXPosition < wordStartX || mouseXPosition > wordEndX))
|
||||
return;
|
||||
|
||||
if (wordSelectionEnabled) {
|
||||
if (suggestedNewPosition < selectedWordOnDoubleClick.position()) {
|
||||
cursor.setPosition(selectedWordOnDoubleClick.selectionEnd());
|
||||
setCursorPosition(wordStartPos, QTextCursor::KeepAnchor);
|
||||
} else {
|
||||
cursor.setPosition(selectedWordOnDoubleClick.selectionStart());
|
||||
setCursorPosition(wordEndPos, QTextCursor::KeepAnchor);
|
||||
}
|
||||
} else {
|
||||
// keep the already selected word even when moving to the left
|
||||
// (#39164)
|
||||
if (suggestedNewPosition < selectedWordOnDoubleClick.position())
|
||||
@ -703,6 +712,7 @@ void QTextControlPrivate::extendWordwiseSelection(int suggestedNewPosition, qrea
|
||||
setCursorPosition(wordStartPos, QTextCursor::KeepAnchor);
|
||||
else
|
||||
setCursorPosition(wordEndPos, QTextCursor::KeepAnchor);
|
||||
}
|
||||
|
||||
if (interactionFlags & Qt::TextSelectableByMouse) {
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
|
Loading…
x
Reference in New Issue
Block a user