diff options
Diffstat (limited to 'src/plugins/platforms/ios/qiostextinputoverlay.mm')
-rw-r--r-- | src/plugins/platforms/ios/qiostextinputoverlay.mm | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/plugins/platforms/ios/qiostextinputoverlay.mm b/src/plugins/platforms/ios/qiostextinputoverlay.mm index 89ace50a82..46dee86279 100644 --- a/src/plugins/platforms/ios/qiostextinputoverlay.mm +++ b/src/plugins/platforms/ios/qiostextinputoverlay.mm @@ -92,6 +92,7 @@ static void executeBlockWithoutAnimation(Block block) @interface QIOSEditMenu : NSObject @property (nonatomic, assign) BOOL visible; @property (nonatomic, readonly) BOOL isHiding; +@property (nonatomic, readonly) BOOL shownByUs; @property (nonatomic, assign) BOOL reshowAfterHidden; @end @@ -110,6 +111,7 @@ static void executeBlockWithoutAnimation(Block block) [center addObserverForName:UIMenuControllerDidHideMenuNotification object:nil queue:nil usingBlock:^(NSNotification *) { _isHiding = NO; + _shownByUs = NO; if (self.reshowAfterHidden) { // To not abort an ongoing hide transition when showing the menu, you can set // reshowAfterHidden to wait until the transition finishes before reshowing it. @@ -144,6 +146,10 @@ static void executeBlockWithoutAnimation(Block block) return; if (visible) { + // UIMenuController is a singleton that can be shown (and hidden) from anywhere. + // Try to keep track of whether or not is was shown by us (the gesture recognizers + // in this file) to avoid closing it if it was opened from elsewhere. + _shownByUs = YES; // Note that the contents of the edit menu is decided by // first responder, which is normally QIOSTextResponder. QRectF cr = qApp->inputMethod()->cursorRectangle(); @@ -492,6 +498,7 @@ static void executeBlockWithoutAnimation(Block block) [self createLoupe]; [self updateFocalPoint:QPointF::fromCGPoint(_lastTouchPoint)]; _loupeLayer.visible = YES; + QIOSTextInputOverlay::s_editMenu.visible = NO; break; case UIGestureRecognizerStateChanged: // Tell the sub class to move the loupe to the correct position @@ -739,6 +746,9 @@ static void executeBlockWithoutAnimation(Block block) QObject::disconnect(_cursorConnection); QObject::disconnect(_anchorConnection); QObject::disconnect(_clipRectConnection); + + if (QIOSTextInputOverlay::s_editMenu.shownByUs) + QIOSTextInputOverlay::s_editMenu.visible = NO; } } @@ -840,20 +850,12 @@ static void executeBlockWithoutAnimation(Block block) if (_cursorLayer.visible) { _cursorLayer.visible = NO; _anchorLayer.visible = NO; - // Only hide the edit menu if we had a selection from before, since - // the edit menu can also be used for other purposes by others (in - // which case we try our best not to interfere). - QIOSTextInputOverlay::s_editMenu.visible = NO; } + if (QIOSTextInputOverlay::s_editMenu.shownByUs) + QIOSTextInputOverlay::s_editMenu.visible = NO; return; } - if (_dragOnCursor || _dragOnAnchor) { - // Ensure that the edit menu is hidden while - // the user drags on any of the handles. - QIOSTextInputOverlay::s_editMenu.visible = NO; - } - if (!_cursorLayer.visible && QIOSTextInputOverlay::s_editMenu.isHiding) { // Since the edit menu is hiding and this is the first selection thereafter, we // assume that the selection came from the user tapping on a menu item. In that |