summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2014-01-31 15:28:07 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-06 14:20:06 +0100
commit865ef951077a641768093ed56950eb39d6b59e63 (patch)
tree3f4be67d4ce3ddb421dd74900ecb2bf1b7ea973f
parentf9a994e707495578de3279d9330f5fb73bae011f (diff)
iOS: be more specific about IM callbacks to iOS
No need to call textWillChange all the time if the text is really not changing. And report that selectionWillChange when Qt reports that it has changed. Change-Id: I7bd9f540cd9302c37888926a6152b803cc871ccb Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
-rw-r--r--src/plugins/platforms/ios/quiview_textinput.mm27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/plugins/platforms/ios/quiview_textinput.mm b/src/plugins/platforms/ios/quiview_textinput.mm
index ff037b5647..64e93be7f2 100644
--- a/src/plugins/platforms/ios/quiview_textinput.mm
+++ b/src/plugins/platforms/ios/quiview_textinput.mm
@@ -154,27 +154,32 @@ Q_GLOBAL_STATIC(StaticVariables, staticVariables);
- (void)updateInputMethodWithQuery:(Qt::InputMethodQueries)query
{
- // TODO: check what changed, and perhaps update delegate if the text was
- // changed from somewhere other than this plugin....
-
- // Note: This function is called both when as a result of the application changing the
- // input, but also (and most commonly) as a response to us sending QInputMethodQueryEvents.
- // Because of the latter, we cannot call textWill/DidChange here, as that will confuse
- // iOS IM handling, and e.g stop spellchecking from working.
Q_UNUSED(query);
QObject *focusObject = QGuiApplication::focusObject();
if (!focusObject)
return;
- if (!m_inSendEventToFocusObject)
- [self.inputDelegate textWillChange:id<UITextInput>(self)];
+ if (!m_inSendEventToFocusObject) {
+ if (query & (Qt::ImCursorPosition | Qt::ImAnchorPosition))
+ [self.inputDelegate selectionWillChange:id<UITextInput>(self)];
+ if (query & Qt::ImSurroundingText)
+ [self.inputDelegate textWillChange:id<UITextInput>(self)];
+ }
+ // Note that we ignore \a query, and instead update using Qt::ImQueryInput. This enables us to just
+ // store the event without copying out the result from the event each time. Besides, we seem to be
+ // called with Qt::ImQueryInput when only changing selection, and always if typing text. So there would
+ // not be any performance gain by only updating \a query.
staticVariables()->inputMethodQueryEvent = QInputMethodQueryEvent(Qt::ImQueryInput);
QCoreApplication::sendEvent(focusObject, &staticVariables()->inputMethodQueryEvent);
- if (!m_inSendEventToFocusObject)
- [self.inputDelegate textDidChange:id<UITextInput>(self)];
+ if (!m_inSendEventToFocusObject) {
+ if (query & (Qt::ImCursorPosition | Qt::ImAnchorPosition))
+ [self.inputDelegate selectionDidChange:id<UITextInput>(self)];
+ if (query & Qt::ImSurroundingText)
+ [self.inputDelegate textDidChange:id<UITextInput>(self)];
+ }
}
- (void)sendEventToFocusObject:(QEvent &)e