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.

Fixes: QTBUG-80298
Change-Id: Iff2032d64db1b582fa7f048c6a1f37ec8a1528af
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
(cherry picked from commit 2e35a03cd624c006b92cb95847231c8b1efde45b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Richard Moe Gustavsen 2021-01-14 11:31:01 +01:00 committed by Qt Cherry-pick Bot
parent c1cd5dcabe
commit 1baf4d9ea4

View File

@ -654,6 +654,7 @@ static void executeBlockWithoutAnimation(Block block)
QIOSHandleLayer *_anchorLayer; QIOSHandleLayer *_anchorLayer;
QPointF _touchOffset; QPointF _touchOffset;
bool _dragOnCursor; bool _dragOnCursor;
bool _dragOnAnchor;
bool _multiLine; bool _multiLine;
QTimer _updateSelectionTimer; QTimer _updateSelectionTimer;
QMetaObject::Connection _cursorConnection; QMetaObject::Connection _cursorConnection;
@ -794,9 +795,11 @@ static void executeBlockWithoutAnimation(Block block)
if (cursorDist < anchorDist) { if (cursorDist < anchorDist) {
_touchOffset = cursorOffset; _touchOffset = cursorOffset;
_dragOnCursor = YES; _dragOnCursor = YES;
_dragOnAnchor = NO;
} else { } else {
_touchOffset = anchorOffset; _touchOffset = anchorOffset;
_dragOnCursor = NO; _dragOnCursor = NO;
_dragOnAnchor = YES;
} }
return YES; return YES;
@ -845,6 +848,12 @@ static void executeBlockWithoutAnimation(Block block)
return; 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) { if (!_cursorLayer.visible && QIOSTextInputOverlay::s_editMenu.isHiding) {
// Since the edit menu is hiding and this is the first selection thereafter, we // 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 // assume that the selection came from the user tapping on a menu item. In that