From 577909b59a52c7d2755d2ce439895641ca93c4ad Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 6 Feb 2014 13:03:37 +0100 Subject: [PATCH] iOS: return correct uiview for IM rectangles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UITextView has a property for specifying which UIView the CGRects you return should be aligned with. This makes a difference for widgets when not using alien, since then the view that draws the text will usually not be the same as the view that backs the top level QWindow. Change-Id: I240d63c98544c39308cd91465ee84351e7d7d1f4 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/quiview_textinput.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/platforms/ios/quiview_textinput.mm b/src/plugins/platforms/ios/quiview_textinput.mm index 64e93be7f2..d0088d415a 100644 --- a/src/plugins/platforms/ios/quiview_textinput.mm +++ b/src/plugins/platforms/ios/quiview_textinput.mm @@ -336,6 +336,18 @@ Q_GLOBAL_STATIC(StaticVariables, staticVariables); return t - f; } +- (UIView *)textInputView +{ + // iOS expects rects we return from other UITextInput methods + // to be relative to the view this method returns. + // Since QInputMethod returns rects relative to the top level + // QWindow, that is also the view we need to return. + QPlatformWindow *topLevel = m_qioswindow; + while (QPlatformWindow *p = topLevel->parent()) + topLevel = p; + return reinterpret_cast(topLevel->winId()); +} + - (CGRect)firstRectForRange:(UITextRange *)range { QObject *focusObject = QGuiApplication::focusObject();