forked from qt-creator/qt-creator
QmlDesigner: Fix hover hightlight of 3D edit icon gizmos
MouseArea.containsMouse gets confused when the mouse input gets grabbed by an overlapping 3D mouse area. Change-Id: I6ee69f217d95c5e4f3f5361e14c932ce0a2feab0 Fixes: QDS-2187 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -42,11 +42,17 @@ Item {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
property bool hasMouse: false
|
||||
|
||||
property alias iconSource: iconImage.source
|
||||
|
||||
signal clicked(Node node, bool multi)
|
||||
|
||||
onSelectedChanged: {
|
||||
if (selected)
|
||||
hasMouse = false;
|
||||
}
|
||||
|
||||
visible: activeScene === scene && (targetNode ? targetNode.visible : false)
|
||||
|
||||
Overlay2D {
|
||||
@@ -57,14 +63,14 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
id: iconRect
|
||||
|
||||
width: iconImage.width
|
||||
height: iconImage.height
|
||||
x: -width / 2
|
||||
y: -height / 2
|
||||
color: "transparent"
|
||||
border.color: "#7777ff"
|
||||
border.width: !iconGizmo.selected
|
||||
&& iconGizmo.highlightOnHover && iconMouseArea.containsMouse ? 2 : 0
|
||||
border.width: iconGizmo.highlightOnHover && iconGizmo.hasMouse ? 2 : 0
|
||||
radius: 5
|
||||
opacity: iconGizmo.selected ? 0.2 : 1
|
||||
Image {
|
||||
@@ -86,6 +92,24 @@ Item {
|
||||
mouse.modifiers & Qt.ControlModifier)
|
||||
hoverEnabled: iconGizmo.highlightOnHover && !iconGizmo.selected
|
||||
acceptedButtons: Qt.LeftButton
|
||||
|
||||
// onPositionChanged, onContainsMouseAreaChanged, and hasMouse are used instead
|
||||
// of just using containsMouse directly, because containsMouse
|
||||
// cannot be relied upon to update correctly in some situations.
|
||||
// This is likely because the overlapping 3D mouse areas of the gizmos get
|
||||
// the mouse events instead of this area, so mouse leaving the area
|
||||
// doesn't always update containsMouse property.
|
||||
onPositionChanged: {
|
||||
if (!iconGizmo.selected)
|
||||
iconGizmo.hasMouse = containsMouse;
|
||||
}
|
||||
|
||||
onContainsMouseChanged: {
|
||||
if (!iconGizmo.selected)
|
||||
iconGizmo.hasMouse = containsMouse;
|
||||
else
|
||||
iconGizmo.hasMouse = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user