diff options
author | Sami Merila <sami.merila@nokia.com> | 2011-10-05 12:06:31 (GMT) |
---|---|---|
committer | Sami Merila <sami.merila@nokia.com> | 2011-10-05 12:06:31 (GMT) |
commit | 2a6298bcf29104a4258992c7357a031f4ca9cc7f (patch) | |
tree | 643b613101eac426cd0868b2ffdf38181372eaff /src/gui/inputmethod | |
parent | 0520b1ce10dc2358d663ee08b53b7de9ce41bb23 (diff) | |
download | Qt-2a6298bcf29104a4258992c7357a031f4ca9cc7f.zip Qt-2a6298bcf29104a4258992c7357a031f4ca9cc7f.tar.gz Qt-2a6298bcf29104a4258992c7357a031f4ca9cc7f.tar.bz2 |
Copy and Cut are not available for some QML editors
Copy and Cut actions do not appear in fullscreen VKB menu when a QML
TextEdit or TextInput element is focused and has selected text.
This happens because input method queries for cursor and anchor
position in QCoeFepInputContext::CcpuCanCut() return zero in this case.
It is probably related to focus changes when the options menu pops up.
When menu pops up from native keyboard, window containing the QML
elements is set as non-active, therefore it loses focus widget, which
in turn causes queries about cursor and anchor positions to return zero.
As a workaround, when there is no microfocus available, ask the
"selectedText" property directly from QML elements.
Task-number: QTBUG-21568
Reviewed-by: Miikka Heikkinen
Diffstat (limited to 'src/gui/inputmethod')
-rw-r--r-- | src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index ff74afe..8f13c53 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -1747,14 +1747,30 @@ TBool QCoeFepInputContext::CcpuCanCut() const if (m_inDestruction) return retval; QWidget *w = focusWidget(); - if (!w) + QObject *focusObject = 0; + if (!w) { w = m_lastFocusedEditor; - else - w = getQWidgetFromQGraphicsView(w); + focusObject = m_lastFocusedObject; + } else { + w = getQWidgetFromQGraphicsView(w, &focusObject); + } if (w) { - int cursor = w->inputMethodQuery(Qt::ImCursorPosition).toInt(); - int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt(); - retval = cursor != anchor; + QRect microFocus = w->inputMethodQuery(Qt::ImMicroFocus).toRect(); + if (microFocus.isNull()) { + // For some reason, the editor does not have microfocus. Most probably, + // it is due to using native fullscreen editing mode with QML apps. + // Try accessing "selectedText" directly. + QObject *invokeTarget = w; + if (focusObject) + invokeTarget = focusObject; + + QString selectedText = invokeTarget->property("selectedText").toString(); + retval = !selectedText.isNull(); + } else { + int cursor = w->inputMethodQuery(Qt::ImCursorPosition).toInt(); + int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt(); + retval = cursor != anchor; + } } return retval; } |