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.
This commit is contained in:
miruka 2020-07-09 22:38:08 -04:00
parent 9612470c9c
commit 657b700fcd

View File

@ -26,6 +26,20 @@ Menu {
color: theme.controls.menu.background color: theme.controls.menu.background
border.color: theme.controls.menu.border border.color: theme.controls.menu.border
border.width: theme.controls.menu.borderWidth 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: { onAboutToShow: {