Improve context menu cursor workaround
- Close menu instead of clicking item, to match behavior of other programs - Now work on all edges of the menu, not just top
This commit is contained in:
parent
d4a0434bd9
commit
e2bc0cbd84
|
@ -27,17 +27,19 @@ Menu {
|
|||
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
|
||||
|
||||
// Workaround for this: when opening menu at mouse position,
|
||||
// cursor will be in menu's border which doesn't handle clicks
|
||||
TapHandler {
|
||||
gesturePolicy: TapHandler.ReleaseWithinBounds
|
||||
onTapped: if (menu.itemAt(0) && menu.itemAt(0).clicked)
|
||||
menu.itemAt(0).clicked()
|
||||
onTapped: eventPoint => {
|
||||
const pos = eventPoint.position
|
||||
const border = parent.border.width
|
||||
|
||||
if (pos.x <= border || pos.x >= parent.width - border)
|
||||
menu.close()
|
||||
|
||||
if (pos.y <= border || pos.y >= parent.height - border)
|
||||
menu.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user