summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-11-21 13:44:26 +0100
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-11-21 13:44:26 +0100
commit245acbf6e81518958228d295bdb6a64298b09351 (patch)
tree10a78831737274c2c55480437e60c74c884fde4d /src/plugins/platforms/ios
parenteb466b636b97251d273aedddfe66b15fe994d375 (diff)
parent087aa1f3cb5975ef55e42db54487f737c93a4f0f (diff)
Merge remote-tracking branch 'origin/5.4.0' into 5.4
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r--src/plugins/platforms/ios/qiosglobal.mm5
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.h3
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.mm27
-rw-r--r--src/plugins/platforms/ios/qiosmenu.mm23
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.mm22
5 files changed, 35 insertions, 45 deletions
diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm
index 9f10c3e287..3ecd0ca61f 100644
--- a/src/plugins/platforms/ios/qiosglobal.mm
+++ b/src/plugins/platforms/ios/qiosglobal.mm
@@ -141,6 +141,11 @@ int infoPlistValue(NSString* key, int defaultValue)
@end
@implementation QtFirstResponderEvent
+- (void) dealloc
+{
+ self.firstResponder = 0;
+ [super dealloc];
+}
@end
diff --git a/src/plugins/platforms/ios/qiosinputcontext.h b/src/plugins/platforms/ios/qiosinputcontext.h
index 1f1130f932..d2a9c261ba 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.h
+++ b/src/plugins/platforms/ios/qiosinputcontext.h
@@ -85,15 +85,12 @@ public:
const ImeState &imeState() { return m_imeState; };
bool inputMethodAccepted() const;
- bool isReloadingInputViewsFromUpdate() const { return m_isReloadingInputViewsFromUpdate; }
-
static QIOSInputContext *instance();
private:
QIOSKeyboardListener *m_keyboardListener;
QIOSTextInputResponder *m_textResponder;
ImeState m_imeState;
- bool m_isReloadingInputViewsFromUpdate;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm
index 072a49c7c5..e417e9a1fb 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.mm
+++ b/src/plugins/platforms/ios/qiosinputcontext.mm
@@ -330,7 +330,6 @@ QIOSInputContext::QIOSInputContext()
: QPlatformInputContext()
, m_keyboardListener([[QIOSKeyboardListener alloc] initWithQIOSInputContext:this])
, m_textResponder(0)
- , m_isReloadingInputViewsFromUpdate(false)
{
if (isQtApplication())
connect(qGuiApp->inputMethod(), &QInputMethod::cursorRectangleChanged, this, &QIOSInputContext::cursorRectangleChanged);
@@ -540,10 +539,11 @@ void QIOSInputContext::update(Qt::InputMethodQueries updatedProperties)
[m_textResponder autorelease];
m_textResponder = [[QIOSTextInputResponder alloc] initWithInputContext:this];
[m_textResponder becomeFirstResponder];
+ } else if ([UIResponder currentFirstResponder] == m_textResponder) {
+ qImDebug() << "IM not enabled, resigning text responder as first responder";
+ [m_textResponder resignFirstResponder];
} else {
- qImDebug() << "IM not enabled, reloading input views";
- QScopedValueRollback<bool> recursionGuard(m_isReloadingInputViewsFromUpdate, true);
- [[UIResponder currentFirstResponder] reloadInputViews];
+ qImDebug() << "IM not enabled. Text responder not first responder. Nothing to do";
}
} else {
[m_textResponder notifyInputDelegate:changedProperties];
@@ -594,22 +594,3 @@ void QIOSInputContext::commit()
[m_textResponder unmarkText];
[m_textResponder notifyInputDelegate:Qt::ImSurroundingText];
}
-
-// -------------------------------------------------------------------------
-
-@interface QUIView (InputMethods)
-- (void)reloadInputViews;
-@end
-
-@implementation QUIView (InputMethods)
-- (void)reloadInputViews
-{
- if (QIOSInputContext::instance()->isReloadingInputViewsFromUpdate()) {
- qImDebug() << "preventing recursion by reloading super";
- [super reloadInputViews];
- } else {
- qImDebug() << "reseting input methods";
- qApp->inputMethod()->reset();
- }
-}
-@end
diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm
index 005b06547e..0f351f785b 100644
--- a/src/plugins/platforms/ios/qiosmenu.mm
+++ b/src/plugins/platforms/ios/qiosmenu.mm
@@ -153,13 +153,29 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_";
[self setDelegate:self];
[self setDataSource:self];
[self selectRow:m_selectedRow inComponent:0 animated:false];
+ [self listenForKeyboardWillHideNotification:YES];
}
return self;
}
+-(void)listenForKeyboardWillHideNotification:(BOOL)listen
+{
+ if (listen) {
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(cancelMenu)
+ name:@"UIKeyboardWillHideNotification" object:nil];
+ } else {
+ [[NSNotificationCenter defaultCenter]
+ removeObserver:self
+ name:@"UIKeyboardWillHideNotification" object:nil];
+ }
+}
+
-(void)dealloc
{
+ [self listenForKeyboardWillHideNotification:NO];
self.toolbar = 0;
[super dealloc];
}
@@ -193,6 +209,7 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_";
- (void)closeMenu
{
+ [self listenForKeyboardWillHideNotification:NO];
if (!m_visibleMenuItems.isEmpty())
QIOSMenu::currentMenu()->handleItemSelected(m_visibleMenuItems.at(m_selectedRow));
else
@@ -201,6 +218,7 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_";
- (void)cancelMenu
{
+ [self listenForKeyboardWillHideNotification:NO];
QIOSMenu::currentMenu()->dismiss();
}
@@ -452,11 +470,11 @@ void QIOSMenu::toggleShowUsingUIPickerView(bool show)
Q_ASSERT(!focusObjectWithPickerView);
focusObjectWithPickerView = qApp->focusWindow()->focusObject();
focusObjectWithPickerView->installEventFilter(this);
- qApp->inputMethod()->update(Qt::ImPlatformData);
+ qApp->inputMethod()->update(Qt::ImEnabled | Qt::ImPlatformData);
} else {
Q_ASSERT(focusObjectWithPickerView);
focusObjectWithPickerView->removeEventFilter(this);
- qApp->inputMethod()->update(Qt::ImPlatformData);
+ qApp->inputMethod()->update(Qt::ImEnabled | Qt::ImPlatformData);
focusObjectWithPickerView = 0;
Q_ASSERT(m_pickerView);
@@ -477,6 +495,7 @@ bool QIOSMenu::eventFilter(QObject *obj, QEvent *event)
imPlatformData.insert(kImePlatformDataInputView, QVariant::fromValue(static_cast<void *>(m_pickerView)));
imPlatformData.insert(kImePlatformDataInputAccessoryView, QVariant::fromValue(static_cast<void *>(m_pickerView.toolbar)));
queryEvent->setValue(Qt::ImPlatformData, imPlatformData);
+ queryEvent->setValue(Qt::ImEnabled, true);
return true;
}
diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm
index e3c73f5222..2fcc7258f7 100644
--- a/src/plugins/platforms/ios/qiostextresponder.mm
+++ b/src/plugins/platforms/ios/qiostextresponder.mm
@@ -268,8 +268,11 @@
qImDebug() << "keyboard was closed, clearing focus object";
m_inputContext->clearCurrentFocusObject();
} else {
- // We've lost responder status because another window was made active
- Q_ASSERT(FirstResponderCandidate::currentCandidate());
+ // We've lost responder status because another Qt window was made active,
+ // another QIOSTextResponder was made first-responder, another UIView was
+ // made first-responder, or the first-responder was cleared globally. In
+ // either of these cases we don't have to do anything.
+ qImDebug() << "lost first responder, but not clearing focus object";
}
return YES;
@@ -282,21 +285,6 @@
reinterpret_cast<QUIView *>(qApp->focusWindow()->handle()->winId()) : 0;
}
-/*!
- iOS uses [UIResponder(Internal) _requiresKeyboardWhenFirstResponder] to check if the
- current responder should bring up the keyboard, which in turn checks if the responder
- supports the UIKeyInput protocol. By dynamically reporting our protocol conformance
- we can control the keyboard visibility depending on whether or not we have a focus
- object with IME enabled.
-*/
-- (BOOL)conformsToProtocol:(Protocol *)protocol
-{
- if (protocol == @protocol(UIKeyInput))
- return m_inputContext->inputMethodAccepted();
-
- return [super conformsToProtocol:protocol];
-}
-
// -------------------------------------------------------------------------
- (void)notifyInputDelegate:(Qt::InputMethodQueries)updatedProperties