iOS: ensure we hide the edit menu while dragging on the selection handles

iOS used to close the edit menu automatically when
the user tapped on the screen (even for menus shown
explicitly using the UIMenuController API). Apperently
this has now changed (probably as a part of
[UIMenuController setMenuVisible:] being deprecated in
iOS 13). So we now need to hide it explicitly instead.

Because of this, the edit menu would be showing together
with the magnifier class while the user was dragging on
any of the handles. This patch will fix this, so that we
close the edit menu explicitly whenever the user starts
dragging on a handle.

Pick-to: 6.0 5.15
Fixes: QTBUG-80298
Change-Id: Iff2032d64db1b582fa7f048c6a1f37ec8a1528af
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Richard Moe Gustavsen 2021-01-14 11:31:01 +01:00
parent 61c3f3539c
commit 2e35a03cd6

View File

@ -654,6 +654,7 @@ static void executeBlockWithoutAnimation(Block block)
QIOSHandleLayer *_anchorLayer;
QPointF _touchOffset;
bool _dragOnCursor;
bool _dragOnAnchor;
bool _multiLine;
QTimer _updateSelectionTimer;
QMetaObject::Connection _cursorConnection;
@ -794,9 +795,11 @@ static void executeBlockWithoutAnimation(Block block)
if (cursorDist < anchorDist) {
_touchOffset = cursorOffset;
_dragOnCursor = YES;
_dragOnAnchor = NO;
} else {
_touchOffset = anchorOffset;
_dragOnCursor = NO;
_dragOnAnchor = YES;
}
return YES;
@ -845,6 +848,12 @@ static void executeBlockWithoutAnimation(Block block)
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