From b19280753d8edfab503669a61800735ad184b042 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 19 Sep 2016 15:08:12 +0200 Subject: iOS: hide shortcuts bar on iPad when showing menus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On iPad, a shortcuts bar with extra controls are shown on top of the keyboard with opertions like cut and copy. This is unwanted when using the keyboard to show menus. This patch will add extra private information to IM platform data when using menus, so that we hide the shorcuts menu when showing the custom input panel. Task-number: QTBUG-49893 Change-Id: Iaa8e1ff18acebec8be69699b3fd9470c69ab34d7 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosinputcontext.h | 1 + src/plugins/platforms/ios/qiosmenu.mm | 1 + src/plugins/platforms/ios/qiostextresponder.mm | 11 +++++++++++ 3 files changed, 13 insertions(+) (limited to 'src/plugins/platforms/ios') diff --git a/src/plugins/platforms/ios/qiosinputcontext.h b/src/plugins/platforms/ios/qiosinputcontext.h index 923c87b07b..f7112dd5c6 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.h +++ b/src/plugins/platforms/ios/qiosinputcontext.h @@ -43,6 +43,7 @@ const char kImePlatformDataInputView[] = "inputView"; const char kImePlatformDataInputAccessoryView[] = "inputAccessoryView"; +const char kImePlatformDataHideShortcutsBar[] = "hideShortcutsBar"; const char kImePlatformDataReturnKeyType[] = "returnKeyType"; QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm index 3e97b1161c..0ba9d9a07b 100644 --- a/src/plugins/platforms/ios/qiosmenu.mm +++ b/src/plugins/platforms/ios/qiosmenu.mm @@ -544,6 +544,7 @@ bool QIOSMenu::eventFilter(QObject *obj, QEvent *event) QVariantMap imPlatformData = queryEvent->value(Qt::ImPlatformData).toMap(); imPlatformData.insert(kImePlatformDataInputView, QVariant::fromValue(static_cast(m_pickerView))); imPlatformData.insert(kImePlatformDataInputAccessoryView, QVariant::fromValue(static_cast(m_pickerView.toolbar))); + imPlatformData.insert(kImePlatformDataHideShortcutsBar, true); queryEvent->setValue(Qt::ImPlatformData, imPlatformData); queryEvent->setValue(Qt::ImEnabled, true); diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index 4bef968de1..d961d4149c 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -230,6 +230,17 @@ self.inputView = [[[WrapperView alloc] initWithView:inputView] autorelease]; if (UIView *accessoryView = static_cast(platformData.value(kImePlatformDataInputAccessoryView).value())) self.inputAccessoryView = [[[WrapperView alloc] initWithView:accessoryView] autorelease]; + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_9_0) { + if (platformData.value(kImePlatformDataHideShortcutsBar).toBool()) { + // According to the docs, leadingBarButtonGroups/trailingBarButtonGroups should be set to nil to hide the shortcuts bar. + // However, starting with iOS 10, the API has been surrounded with NS_ASSUME_NONNULL, which contradicts this and causes + // compiler warnings. And assigning just an empty array causes layout asserts. Hence, we assign empty button groups instead. + UIBarButtonItemGroup *leading = [[[UIBarButtonItemGroup alloc] initWithBarButtonItems:@[] representativeItem:nil] autorelease]; + UIBarButtonItemGroup *trailing = [[[UIBarButtonItemGroup alloc] initWithBarButtonItems:@[] representativeItem:nil] autorelease]; + self.inputAssistantItem.leadingBarButtonGroups = @[leading]; + self.inputAssistantItem.trailingBarButtonGroups = @[trailing]; + } + } self.undoManager.groupsByEvent = NO; [self rebuildUndoStack]; -- cgit v1.2.3 From 3f8843f18dc339758743f727d4828d1f914fde63 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 21 Apr 2016 10:14:23 +0200 Subject: iOS: (crash fix) ensure we don't clear focus object in a text responder transition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (Backport of 5.7/8586ccc). The original patch was implemented to handle crashes after e78ca787ae459f. But the former was pushed to 5.7, and the latter to 5.6. So we need to backport it, otherwise the same crashes will still happen in 5.6 (e.g when transferring focus from a text edit to a (picker) menu). Change-Id: I13037735dc316bceadb571e67f38a310c8a1bfae Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiostextresponder.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms/ios') diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index d961d4149c..6224a6603c 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -329,7 +329,7 @@ // a regular responder transfer to another window. In the former case, iOS // 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]) { + if (![UIResponder currentFirstResponder] && !FirstResponderCandidate::currentCandidate()) { // No first responder set anymore, sync this with Qt by clearing the // focus object. m_inputContext->clearCurrentFocusObject(); -- cgit v1.2.3