Make expandable component dragable.

This commit is contained in:
Remco Burema 2019-04-20 00:15:42 +02:00
parent 46403a0fde
commit 28a14c0a3b
2 changed files with 28 additions and 0 deletions

View File

@ -225,6 +225,33 @@ Item
left: parent.left left: parent.left
} }
MouseArea
{
id: dragRegion
anchors
{
top: parent.top
bottom: parent.bottom
left: parent.left
right: contentHeader.xPosCloseButton
}
property variant clickPos: Qt.point(0, 0)
onPressed:
{
clickPos = Qt.point(mouse.x, mouse.y);
}
onPositionChanged:
{
var delta = Qt.point(mouse.x - clickPos.x, mouse.y - clickPos.y);
if (delta.x != 0 || delta.y != 0)
{
contentContainer.x += delta.x;
contentContainer.y += delta.y;
}
}
}
} }
Control Control

View File

@ -13,6 +13,7 @@ Cura.RoundedRectangle
id: header id: header
property alias headerTitle: headerLabel.text property alias headerTitle: headerLabel.text
property alias xPosCloseButton: closeButton.left
height: UM.Theme.getSize("expandable_component_content_header").height height: UM.Theme.getSize("expandable_component_content_header").height
color: UM.Theme.getColor("secondary") color: UM.Theme.getColor("secondary")