Multiline editors not to limit anchor position inputMethodQuery
The queries were limited to current block, because that is the available surrounding text. Input method side, however, cannot then distinguish between anchor being really at start or end of the surrounding text, or beyond it. Without the limitation there at least is a way to know anchor is at unknown territory. Change-Id: I388d33566388344ec816ea7d86662b7e36a3d7d0 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>bb10
parent
3172631f0d
commit
29aa93387b
|
|
@ -1896,7 +1896,7 @@ QVariant QTextControl::inputMethodQuery(Qt::InputMethodQuery property) const
|
|||
case Qt::ImMaximumTextLength:
|
||||
return QVariant(); // No limit.
|
||||
case Qt::ImAnchorPosition:
|
||||
return QVariant(qBound(0, d->cursor.anchor() - block.position(), block.length()));
|
||||
return QVariant(d->cursor.anchor() - block.position());
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2006,7 +2006,7 @@ QVariant QWidgetTextControl::inputMethodQuery(Qt::InputMethodQuery property) con
|
|||
case Qt::ImMaximumTextLength:
|
||||
return QVariant(); // No limit.
|
||||
case Qt::ImAnchorPosition:
|
||||
return QVariant(qBound(0, d->cursor.anchor() - block.position(), block.length()));
|
||||
return QVariant(d->cursor.anchor() - block.position());
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,6 +203,7 @@ private slots:
|
|||
void bidiLogicalMovement();
|
||||
|
||||
void inputMethodSelection();
|
||||
void inputMethodQuery();
|
||||
|
||||
private:
|
||||
void createSelection();
|
||||
|
|
@ -2386,6 +2387,18 @@ void tst_QTextEdit::inputMethodSelection()
|
|||
QCOMPARE(ed->textCursor().selectionEnd(), 17);
|
||||
}
|
||||
|
||||
void tst_QTextEdit::inputMethodQuery()
|
||||
{
|
||||
QString text("first line of text\nsecond line of text");
|
||||
ed->setText(text);
|
||||
ed->selectAll();
|
||||
|
||||
QInputMethodQueryEvent event(Qt::ImQueryInput);
|
||||
QGuiApplication::sendEvent(ed, &event);
|
||||
int anchor = event.value(Qt::ImAnchorPosition).toInt();
|
||||
int position = event.value(Qt::ImCursorPosition).toInt();
|
||||
QCOMPARE(qAbs(position - anchor), text.length());
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QTextEdit)
|
||||
#include "tst_qtextedit.moc"
|
||||
|
|
|
|||
Loading…
Reference in New Issue