From 657b700fcd3fc324da8c8d8edcbdc317c2a01cd3 Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 9 Jul 2020 22:38:08 -0400 Subject: [PATCH] Context menu initial cursor position workaround Workaround for this: when opening a context menu at cursor position, cursor will be in the menu's border instead of first menu item, forcing the user to move the mouse for the click to do anything. --- src/gui/Base/HMenu.qml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gui/Base/HMenu.qml b/src/gui/Base/HMenu.qml index 37dd7b2b..8ea6fc54 100644 --- a/src/gui/Base/HMenu.qml +++ b/src/gui/Base/HMenu.qml @@ -26,6 +26,20 @@ Menu { color: theme.controls.menu.background border.color: theme.controls.menu.border border.width: theme.controls.menu.borderWidth + + Item { + // Workaround for this: when opening the menu at cursor position, + // cursor will be in the menu's border instead of first menu item, + // forcing the user to move the mouse for the click to do anything. + width: parent.width + height: parent.border.width + + TapHandler { + gesturePolicy: TapHandler.ReleaseWithinBounds + onTapped: if (menu.itemAt(0) && menu.itemAt(0).clicked) + menu.itemAt(0).clicked() + } + } } onAboutToShow: {