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;
|
return false;
|
||||||
}
|
}
|
||||||
|
property bool hasMouse: false
|
||||||
|
|
||||||
property alias iconSource: iconImage.source
|
property alias iconSource: iconImage.source
|
||||||
|
|
||||||
signal clicked(Node node, bool multi)
|
signal clicked(Node node, bool multi)
|
||||||
|
|
||||||
|
onSelectedChanged: {
|
||||||
|
if (selected)
|
||||||
|
hasMouse = false;
|
||||||
|
}
|
||||||
|
|
||||||
visible: activeScene === scene && (targetNode ? targetNode.visible : false)
|
visible: activeScene === scene && (targetNode ? targetNode.visible : false)
|
||||||
|
|
||||||
Overlay2D {
|
Overlay2D {
|
||||||
@@ -57,14 +63,14 @@ Item {
|
|||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: iconRect
|
id: iconRect
|
||||||
|
|
||||||
width: iconImage.width
|
width: iconImage.width
|
||||||
height: iconImage.height
|
height: iconImage.height
|
||||||
x: -width / 2
|
x: -width / 2
|
||||||
y: -height / 2
|
y: -height / 2
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
border.color: "#7777ff"
|
border.color: "#7777ff"
|
||||||
border.width: !iconGizmo.selected
|
border.width: iconGizmo.highlightOnHover && iconGizmo.hasMouse ? 2 : 0
|
||||||
&& iconGizmo.highlightOnHover && iconMouseArea.containsMouse ? 2 : 0
|
|
||||||
radius: 5
|
radius: 5
|
||||||
opacity: iconGizmo.selected ? 0.2 : 1
|
opacity: iconGizmo.selected ? 0.2 : 1
|
||||||
Image {
|
Image {
|
||||||
@@ -86,6 +92,24 @@ Item {
|
|||||||
mouse.modifiers & Qt.ControlModifier)
|
mouse.modifiers & Qt.ControlModifier)
|
||||||
hoverEnabled: iconGizmo.highlightOnHover && !iconGizmo.selected
|
hoverEnabled: iconGizmo.highlightOnHover && !iconGizmo.selected
|
||||||
acceptedButtons: Qt.LeftButton
|
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