QWidget: always handle IM queries

A widget (e.g QLineEdit) will set WA_InputMethodEnabled to
false if it's read-only. But it can still contain selected
text (e.g from a mouse drag). In many cases, it therefore
makes sense to be able to query the focus object for what
that selection is, e.g to be able to show selection handles
from the QPA plugin (iOS/Android).

Therefore, remove the check if a widget has WA_InputMethodEnabled,
and always process the query. The caller can always check this
flag himself (or Qt::ImEnabled) before sending the query, if needed.

Task-number: QTBUG-91545
Change-Id: Ia3dfa289283b5c157ba47cf0b508f9fddadd2861
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Richard Moe Gustavsen 2021-11-04 11:03:17 +01:00
parent 453695ec92
commit 7c6e4af483

View File

@ -8891,8 +8891,7 @@ bool QWidget::event(QEvent *event)
inputMethodEvent((QInputMethodEvent *) event);
break;
case QEvent::InputMethodQuery:
if (testAttribute(Qt::WA_InputMethodEnabled)) {
case QEvent::InputMethodQuery: {
QInputMethodQueryEvent *query = static_cast<QInputMethodQueryEvent *>(event);
Qt::InputMethodQueries queries = query->queries();
for (uint i = 0; i < 32; ++i) {