summaryrefslogtreecommitdiff
path: root/src/plugins/platforms/ios
diff options
context:
space:
mode:
authorTor Arne Vestbø <torarnv@gmail.com>2021-02-10 12:09:17 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-04-09 14:19:25 +0000
commit331096f8d3f3bc7d76ea3e16080cfb9cc9f06eaa (patch)
tree13d969a0b7104a196f3264b15979abf9cc00572b /src/plugins/platforms/ios
parent50d5e6712384457bec4d6d4d13930c995b3611aa (diff)
downloadqtbase-331096f8d3f3bc7d76ea3e16080cfb9cc9f06eaa.tar.gz
iOS: Disable three-finger-tap editing interaction menu when there's no focus object
A typical Qt application, such as a QML application, is a single full screen QUIView, containing all of the granular controls of the UI. The view accepts first responder status, so that we can pass on text input to a possible text field inside the UI. That however triggers iOS to bring up the editing interaction menu whenever the user taps with three fingers, as iOS can't know that only parts of our view is suitable for interaction. To mitigate that we override the editingInteractionConfiguration getter of the view, as documented, and dynamically report the correct enablement based on whether we have an active focus object that accepts input. This works because iOS queries the getter from the three finger tap gesture recognizer, before showing the menu. Change-Id: I0874340c42e437e1d7251896993f2eafe122f09e Fixes: QTBUG-89735 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit f0f00dbd119e0169bc81aa761e4d548e4ecf2214) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r--src/plugins/platforms/ios/quiview.mm13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm
index cf78c57fca..e4025b7794 100644
--- a/src/plugins/platforms/ios/quiview.mm
+++ b/src/plugins/platforms/ios/quiview.mm
@@ -45,6 +45,7 @@
#include "qiostextresponder.h"
#include "qiosscreen.h"
#include "qioswindow.h"
+#include "qiosinputcontext.h"
#ifndef Q_OS_TVOS
#include "qiosmenu.h"
#endif
@@ -653,6 +654,18 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
[super addInteraction:interaction];
}
+- (UIEditingInteractionConfiguration)editingInteractionConfiguration
+{
+ // We only want the three-finger-tap edit menu to be available when there's
+ // actually something to edit. Otherwise the OS will cause a slight delay
+ // before delivering the release of three finger touch input. Note that we
+ // do not do any hit testing here to check that the focus object is the one
+ // being tapped, as the behavior of native iOS apps is to trigger the menu
+ // regardless of where the gesture is being made.
+ return QIOSInputContext::instance()->inputMethodAccepted() ?
+ UIEditingInteractionConfigurationDefault : UIEditingInteractionConfigurationNone;
+}
+
@end
@implementation UIView (QtHelpers)