summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2014-12-18 12:12:58 +0100
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2014-12-18 12:12:58 +0100
commite281537f2049af0b96fd87158f2b7212afe8ab5f (patch)
tree7f9e3b14a2456cc779aa165457192094507dd257 /src/plugins/platforms/ios
parente0a8b5ce88bc50440dcec2fe3a86d83e2a7dc7b0 (diff)
parent84569773db68408704193268bc42a200bb25a924 (diff)
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts: src/corelib/global/qglobal.h src/platformsupport/platformcompositor/qopenglcompositor.cpp src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp tests/auto/gui/kernel/qwindow/tst_qwindow.cpp Change-Id: I5422868500be695584a496dbbbc719d146bc572d
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.h1
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.mm52
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.mm10
3 files changed, 36 insertions, 27 deletions
diff --git a/src/plugins/platforms/ios/qiosinputcontext.h b/src/plugins/platforms/ios/qiosinputcontext.h
index 863e503c3b..498db45ef2 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.h
+++ b/src/plugins/platforms/ios/qiosinputcontext.h
@@ -96,7 +96,6 @@ public:
void setFocusObject(QObject *object) Q_DECL_OVERRIDE;
void focusWindowChanged(QWindow *focusWindow);
- void cursorRectangleChanged();
void scrollToCursor();
void scroll(int y);
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm
index fe9ee18155..76c02d939f 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.mm
+++ b/src/plugins/platforms/ios/qiosinputcontext.mm
@@ -68,6 +68,7 @@ static QUIView *focusView()
@private
QIOSInputContext *m_context;
}
+@property BOOL hasDeferredScrollToCursor;
@end
@implementation QIOSKeyboardListener
@@ -80,6 +81,8 @@ static QUIView *focusView()
m_context = context;
+ self.hasDeferredScrollToCursor = NO;
+
// UIGestureRecognizer
self.enabled = NO;
self.cancelsTouchesInView = NO;
@@ -159,6 +162,18 @@ static QUIView *focusView()
// -------------------------------------------------------------------------
+- (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)other
+{
+ Q_UNUSED(other);
+ return NO;
+}
+
+- (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)other
+{
+ Q_UNUSED(other);
+ return NO;
+}
+
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
@@ -231,9 +246,14 @@ static QUIView *focusView()
qImDebug() << "keyboard was hidden, disabling hide-keyboard gesture";
self.enabled = NO;
} else {
- qImDebug() << "gesture completed without triggering, scrolling view to cursor";
- m_context->scrollToCursor();
+ qImDebug() << "gesture completed without triggering";
+ if (self.hasDeferredScrollToCursor) {
+ qImDebug() << "applying deferred scroll to cursor";
+ m_context->scrollToCursor();
+ }
}
+
+ self.hasDeferredScrollToCursor = NO;
}
@end
@@ -281,8 +301,6 @@ QIOSInputContext::QIOSInputContext()
if (isQtApplication()) {
QIOSScreen *iosScreen = static_cast<QIOSScreen*>(QGuiApplication::primaryScreen()->handle());
[iosScreen->uiWindow() addGestureRecognizer:m_keyboardHideGesture];
-
- connect(qGuiApp->inputMethod(), &QInputMethod::cursorRectangleChanged, this, &QIOSInputContext::cursorRectangleChanged);
}
connect(qGuiApp, &QGuiApplication::focusWindowChanged, this, &QIOSInputContext::focusWindowChanged);
@@ -400,23 +418,6 @@ QRectF QIOSInputContext::keyboardRect() const
// -------------------------------------------------------------------------
-void QIOSInputContext::cursorRectangleChanged()
-{
- if (!isInputPanelVisible() || !qApp->focusObject())
- return;
-
- // Check if the cursor has changed position inside the input item. Since
- // qApp->inputMethod()->cursorRectangle() will also change when the input item
- // itself moves, we need to ask the focus object for ImCursorRectangle:
- static QPoint prevCursor;
- QInputMethodQueryEvent queryEvent(Qt::ImCursorRectangle);
- QCoreApplication::sendEvent(qApp->focusObject(), &queryEvent);
- QPoint cursor = queryEvent.value(Qt::ImCursorRectangle).toRect().topLeft();
- if (cursor != prevCursor)
- scrollToCursor();
- prevCursor = cursor;
-}
-
UIView *QIOSInputContext::scrollableRootView()
{
if (!m_keyboardHideGesture.view)
@@ -437,7 +438,8 @@ void QIOSInputContext::scrollToCursor()
if (m_keyboardHideGesture.state == UIGestureRecognizerStatePossible && m_keyboardHideGesture.numberOfTouches == 1) {
// Don't scroll to the cursor if the user is touching the screen and possibly
// trying to trigger the hide-keyboard gesture.
- qImDebug() << "preventing scrolling to cursor as we're still waiting for a possible gesture";
+ qImDebug() << "deferring scrolling to cursor as we're still waiting for a possible gesture";
+ m_keyboardHideGesture.hasDeferredScrollToCursor = YES;
return;
}
@@ -524,7 +526,8 @@ void QIOSInputContext::setFocusObject(QObject *focusObject)
qImDebug() << "new focus object =" << focusObject;
- if (m_keyboardHideGesture.state == UIGestureRecognizerStateChanged) {
+ if (QPlatformInputContext::inputMethodAccepted()
+ && m_keyboardHideGesture.state == UIGestureRecognizerStateChanged) {
// A new focus object may be set as part of delivering touch events to
// application during the hide-keyboard gesture, but we don't want that
// to result in a new object getting focus and bringing the keyboard up
@@ -598,6 +601,9 @@ void QIOSInputContext::update(Qt::InputMethodQueries updatedProperties)
} else {
[m_textResponder notifyInputDelegate:changedProperties];
}
+
+ if (changedProperties & Qt::ImCursorRectangle)
+ scrollToCursor();
}
bool QIOSInputContext::inputMethodAccepted() const
diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm
index 2fcc7258f7..bebc7577f8 100644
--- a/src/plugins/platforms/ios/qiostextresponder.mm
+++ b/src/plugins/platforms/ios/qiostextresponder.mm
@@ -263,10 +263,14 @@
// will set the new first-responder to our next-responder, and in the latter
// case we'll have an active responder candidate.
if ([UIResponder currentFirstResponder] == [self nextResponder]) {
- // We have resigned the keyboard, and transferred back to the parent view, so unset focus object
+ // We have resigned the keyboard, and transferred first responder back to the parent view
Q_ASSERT(!FirstResponderCandidate::currentCandidate());
- qImDebug() << "keyboard was closed, clearing focus object";
- m_inputContext->clearCurrentFocusObject();
+ if ([self imValue:Qt::ImEnabled].toBool()) {
+ // The current focus object expects text input, but there
+ // is no keyboard to get input from. So we clear focus.
+ qImDebug() << "no keyboard available, clearing focus object";
+ m_inputContext->clearCurrentFocusObject();
+ }
} else {
// We've lost responder status because another Qt window was made active,
// another QIOSTextResponder was made first-responder, another UIView was