From 7eb8b67c8bc8e69b3dd6fb39dde09ac36f56e538 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 15 Jan 2014 10:40:13 +0100 Subject: iOS: implement support for input methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change will add support for input methods, word completion, spell checking and related functionality. Change-Id: I41d4de1cab521c679d414cfc7c1a2d0f9c1fcaaf Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosinputcontext.mm | 38 ++++++++++++++++----------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'src/plugins/platforms/ios/qiosinputcontext.mm') diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm index c25d76518f..15f5082f62 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.mm +++ b/src/plugins/platforms/ios/qiosinputcontext.mm @@ -42,6 +42,7 @@ #include "qiosglobal.h" #include "qiosinputcontext.h" #include "qioswindow.h" +#include "quiview.h" #include @interface QIOSKeyboardListener : NSObject { @@ -228,23 +229,12 @@ void QIOSInputContext::setFocusObject(QObject *focusObject) { m_focusObject = focusObject; - if (!m_focusView || !m_focusView.isFirstResponder) { + if (!focusObject || !m_focusView || !m_focusView.isFirstResponder) { scroll(0); return; } - // Since m_focusView is the first responder, it means that the keyboard is open and we - // should update keyboard layout. But there seem to be no way to tell it to reread the - // UITextInputTraits from m_focusView. To work around that, we quickly resign first - // responder status just to reassign it again. To not remove the focusObject in the same - // go, we need to call the super implementation of resignFirstResponder. Since the call - // will cause a 'keyboardWillHide' notification to be sendt, we also block scrollRootView - // to avoid artifacts: - m_keyboardListener->m_ignoreKeyboardChanges = true; - SEL sel = @selector(resignFirstResponder); - [[m_focusView superclass] instanceMethodForSelector:sel](m_focusView, sel); - [m_focusView becomeFirstResponder]; - m_keyboardListener->m_ignoreKeyboardChanges = false; + reset(); if (m_keyboardListener->m_keyboardVisibleAndDocked) scrollToCursor(); @@ -252,8 +242,7 @@ void QIOSInputContext::setFocusObject(QObject *focusObject) void QIOSInputContext::focusWindowChanged(QWindow *focusWindow) { - UIView *view = focusWindow ? - reinterpret_cast *>(focusWindow->handle()->winId()) : 0; + QUIView *view = focusWindow ? reinterpret_cast(focusWindow->handle()->winId()) : 0; if ([m_focusView isFirstResponder]) [view becomeFirstResponder]; [m_focusView release]; @@ -315,3 +304,22 @@ void QIOSInputContext::scroll(int y) completion:0]; } +void QIOSInputContext::update(Qt::InputMethodQueries query) +{ + [m_focusView updateInputMethodWithQuery:query]; +} + +void QIOSInputContext::reset() +{ + // Since the call to reset will cause a 'keyboardWillHide' + // notification to be sendt, we block keyboard nofifications to avoid artifacts: + m_keyboardListener->m_ignoreKeyboardChanges = true; + [m_focusView reset]; + m_keyboardListener->m_ignoreKeyboardChanges = false; +} + +void QIOSInputContext::commit() +{ + [m_focusView commit]; +} + -- cgit v1.2.3