QmlDesigner: Intercept stray mouse events on popup menus

By default Qt Quick Controls Menu lets mouse events through to the
underlying view if the event is not handled by the menu item.
This is the case for all clicks on disabled items and right clicks
on enabled items.

To prevent unwanted click-throughs, added a mouse area to the
background of StudioControls.Menu that eats all clicks.

Fixes: QDS-8584
Change-Id: I08fa93317ffcaf518b350d44bb555d84741e246d
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Miikka Heikkinen
2022-12-12 15:43:54 +02:00
parent 432c5cd652
commit c476a1b807

View File

@@ -40,5 +40,13 @@ T.Menu {
color: StudioTheme.Values.themeControlBackground
border.color: StudioTheme.Values.themeControlOutline
border.width: StudioTheme.Values.border
MouseArea {
// This mouse area is here to eat clicks that are not handled by menu items
// to prevent them going through to the underlying view.
// This is primarily problem with disabled menu items, but right clicks would go
// through enabled menu items as well.
anchors.fill: parent
acceptedButtons: Qt.AllButtons
}
}
}