Commit b8af05e6 authored by Jörg Schummer's avatar Jörg Schummer Committed by Kai Koehne

QmlDesigner.ItemLibrary: fixed item dragging and selection

- itemDragged is emitted only once now after a minimal distance
  has been reached (minimal distance calculcation not exact)
- onPressed is used instead of onClicked for item selection
parent 78b31454
......@@ -37,7 +37,7 @@ Item {
width: GridView.view.cellWidth
height: style.cellHeight
signal itemClicked()
signal itemPressed()
signal itemDragged()
Rectangle {
......@@ -116,12 +116,25 @@ Item {
id: mouseRegion
anchors.fill: parent
onPositionChanged: {
itemDragged();
property bool reallyPressed: false
property int pressedX
property int pressedY
onPressed: {
reallyPressed = true
pressedX = mouse.x
pressedY = mouse.y
itemPressed()
}
onClicked: {
itemClicked();
onPositionChanged: {
if (reallyPressed &&
(Math.abs(mouse.x - pressedX) > 2 ||
Math.abs(mouse.y - pressedY) > 2)) {
itemDragged()
reallyPressed = false;
}
}
onReleased: reallyPressed = false
}
}
......@@ -58,7 +58,7 @@ Column {
sectionView.itemSelected(itemLibId);
}
onItemClicked: selectItem()
onItemPressed: selectItem()
onItemDragged: {
selectItem();
sectionView.itemDragged(itemLibId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment