From f9d219b92636fc279a3dc0c0e667b6668d0943db Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 27 Apr 2020 14:55:01 +0200 Subject: iOS: Teach edit menu popover to have a readonly mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We should have foreseen the need for customizing this menu in 2014 when Controls 1 needed it, but here we are: Qt 5 is "done", this still wasn't done, and it's too late for new enum values in 5.15. So the workaround is to add a property on the focus object that the iOS plugin can query, and give us a menu that has Copy instead of Paste. Task-number: QTBUG-83811 Change-Id: Id8d18260002952fe7aa77aa5608cf7d0e440dacb Reviewed-by: Richard Moe Gustavsen Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiostextresponder.mm | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/plugins/platforms/ios') diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index a3350bda87..19e476a064 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -416,6 +416,17 @@ if (unknownAction) return [super canPerformAction:action withSender:sender]; + + QObject *focusObject = QGuiApplication::focusObject(); + if (focusObject && focusObject->property("qt_im_readonly").toBool()) { + // exceptional menu items for read-only views: do include Copy, do not include Paste etc. + if (action == @selector(cut:) + || action == @selector(paste:) + || action == @selector(delete:)) + return NO; + if (action == @selector(copy:)) + return YES; + } return (hasSelection && isEditAction) || (!hasSelection && isSelectAction); } -- cgit v1.2.3