Android: Enable text selection only when ImhNoPredictiveText is set.
Mouse selection does not work well with Android and text will be randomly copied, pasted or deleted. This behavior is especially bad when predictive text is enabled. Task-number: QTBUG-34616 Change-Id: I732ad7db52169bfb5735c237cf24597a3d6d64ba Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
This commit is contained in:
parent
a03a69efb9
commit
de5ae6917c
@ -1493,6 +1493,9 @@ void QLineEdit::mousePressEvent(QMouseEvent* e)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool mark = e->modifiers() & Qt::ShiftModifier;
|
bool mark = e->modifiers() & Qt::ShiftModifier;
|
||||||
|
#ifdef Q_OS_ANDROID
|
||||||
|
mark = mark && (d->imHints & Qt::ImhNoPredictiveText);
|
||||||
|
#endif // Q_OS_ANDROID
|
||||||
int cursor = d->xToPos(e->pos().x());
|
int cursor = d->xToPos(e->pos().x());
|
||||||
#ifndef QT_NO_DRAGANDDROP
|
#ifndef QT_NO_DRAGANDDROP
|
||||||
if (!mark && d->dragEnabled && d->control->echoMode() == Normal &&
|
if (!mark && d->dragEnabled && d->control->echoMode() == Normal &&
|
||||||
@ -1520,14 +1523,19 @@ void QLineEdit::mouseMoveEvent(QMouseEvent * e)
|
|||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (d->control->composeMode()) {
|
#ifndef Q_OS_ANDROID
|
||||||
|
const bool select = true;
|
||||||
|
#else
|
||||||
|
const bool select = (d->imHints & Qt::ImhNoPredictiveText);
|
||||||
|
#endif
|
||||||
|
if (d->control->composeMode() && select) {
|
||||||
int startPos = d->xToPos(d->mousePressPos.x());
|
int startPos = d->xToPos(d->mousePressPos.x());
|
||||||
int currentPos = d->xToPos(e->pos().x());
|
int currentPos = d->xToPos(e->pos().x());
|
||||||
if (startPos != currentPos)
|
if (startPos != currentPos)
|
||||||
d->control->setSelection(startPos, currentPos - startPos);
|
d->control->setSelection(startPos, currentPos - startPos);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
d->control->moveCursor(d->xToPos(e->pos().x()), true);
|
d->control->moveCursor(d->xToPos(e->pos().x()), select);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,12 @@ void QLineEditPrivate::_q_completionHighlighted(QString newText)
|
|||||||
QString text = control->text();
|
QString text = control->text();
|
||||||
q->setText(text.left(c) + newText.mid(c));
|
q->setText(text.left(c) + newText.mid(c));
|
||||||
control->moveCursor(control->end(), false);
|
control->moveCursor(control->end(), false);
|
||||||
control->moveCursor(c, true);
|
#ifndef Q_OS_ANDROID
|
||||||
|
const bool mark = true;
|
||||||
|
#else
|
||||||
|
const bool mark = (imHints & Qt::ImhNoPredictiveText);
|
||||||
|
#endif
|
||||||
|
control->moveCursor(c, mark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user