iOS: hide shortcuts bar on iPad when showing menus
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ø <tor.arne.vestbo@theqtcompany.com>
This commit is contained in:
parent
be13081dd4
commit
b19280753d
@ -43,6 +43,7 @@
|
||||
|
||||
const char kImePlatformDataInputView[] = "inputView";
|
||||
const char kImePlatformDataInputAccessoryView[] = "inputAccessoryView";
|
||||
const char kImePlatformDataHideShortcutsBar[] = "hideShortcutsBar";
|
||||
const char kImePlatformDataReturnKeyType[] = "returnKeyType";
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -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<void *>(m_pickerView)));
|
||||
imPlatformData.insert(kImePlatformDataInputAccessoryView, QVariant::fromValue(static_cast<void *>(m_pickerView.toolbar)));
|
||||
imPlatformData.insert(kImePlatformDataHideShortcutsBar, true);
|
||||
queryEvent->setValue(Qt::ImPlatformData, imPlatformData);
|
||||
queryEvent->setValue(Qt::ImEnabled, true);
|
||||
|
||||
|
@ -230,6 +230,17 @@
|
||||
self.inputView = [[[WrapperView alloc] initWithView:inputView] autorelease];
|
||||
if (UIView *accessoryView = static_cast<UIView *>(platformData.value(kImePlatformDataInputAccessoryView).value<void *>()))
|
||||
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];
|
||||
|
Loading…
Reference in New Issue
Block a user