| The Following 2 Users Say Thank You to Markkyboy For This Useful Post: | ||
|
|
2017-04-19
, 13:25
|
|
|
Posts: 394 |
Thanked: 1,341 times |
Joined on Dec 2009
|
#2
|

| The Following 4 Users Say Thank You to velox For This Useful Post: | ||
|
|
2017-04-19
, 16:07
|
|
|
Posts: 433 |
Thanked: 727 times |
Joined on Oct 2012
@ Costa Blanca, España
|
#3
|
Rectangle {
id: rect
anchors {
top: parent.top
topMargin: Theme.paddingMedium
horizontalCenter: parent.horizontalCenter
//......other code
}
MouseArea {
//....other code
onPressed: {
rect.anchors.top = undefined
rect.anchors.topMargin = undefined
rect.anchors.horizontalCenter = undefined
}
}
| The Following User Says Thank You to Markkyboy For This Useful Post: | ||
|
|
2017-04-19
, 17:03
|
|
|
Posts: 433 |
Thanked: 727 times |
Joined on Oct 2012
@ Costa Blanca, España
|
#5
|
Item {
id: foo
anchors.fill: parent
Rectangle {
id: rect
width: 270; height: 270
color: "transparent"
anchors {
top: parent.top
topMargin: -Theme.paddingMedium
horizontalCenter: parent.horizontalCenter
}
Drag.active: dragArea.drag.active
Rectangle {
width: 270; height: 270
opacity: 0.5; radius: 90
color: Theme.highlightDimmerColor
anchors.centerIn: rect
}
MouseArea {
id: dragArea
anchors.fill: parent
drag.target: rect
drag.axis: Drag.XandYAxis
drag.minimumX: 10
drag.maximumX: 270
drag.minimumY: -10
drag.maximumY: 600
//these numbers work in landscape
//drag.minimumX: 10
//drag.maximumX: 680
//drag.minimumY: 10
//drag.maximumY: 200
onPressed: {
rect.anchors.top = undefined
rect.anchors.topMargin = undefined
rect.anchors.horizontalCenter = undefined
}
}
}
}
| The Following User Says Thank You to Markkyboy For This Useful Post: | ||
|
|
2017-04-19
, 18:45
|
|
|
Posts: 394 |
Thanked: 1,341 times |
Joined on Dec 2009
|
#6
|
| The Following User Says Thank You to velox For This Useful Post: | ||
|
|
2017-04-19
, 19:30
|
|
|
Posts: 433 |
Thanked: 727 times |
Joined on Oct 2012
@ Costa Blanca, España
|
#7
|
| The Following User Says Thank You to Markkyboy For This Useful Post: | ||
|
|
2017-04-19
, 20:07
|
|
Posts: 578 |
Thanked: 994 times |
Joined on Dec 2012
|
#8
|
I don't have use of QtCreator or SFOS sdk (couldn't get either to work)
import QtQuick 2.0
import Sailfish.Silica 1.0
Page {
id: page
Item {
id: foo
anchors.fill: parent
Rectangle {
id: rect
width: 270; height: 270
color: "transparent"
// y: Theme.paddingMedium
// x: (page.width - rect.width) /2
// Drag.active: dragArea.drag.active ??
Component.onCompleted: {
y = Theme.paddingMedium
x = (page.width - rect.width) /2
}
Rectangle {
width: 270; height: 270
opacity: 0.9; radius: 90
color: Theme.highlightDimmerColor
anchors.centerIn: rect
}
MouseArea {
id: dragArea
anchors.fill: parent
property real dragMaxX: page.width - Theme.paddingMedium - rect.width
property real dragMaxY: page.height - Theme.paddingMedium - Theme.itemSizeHuge - rect.height
drag.target: rect
drag.axis: Drag.XandYAxis
drag.minimumX: Theme.paddingMedium
drag.maximumX: dragMaxX
drag.minimumY: Theme.paddingMedium
drag.maximumY: dragMaxY
Label {
anchors.centerIn: parent
text: "x: " + Math.round(rect.x) + "\ny: " + Math.round(rect.y)
}
drag.onMaximumXChanged: {
if (rect.x > dragMaxX)
rect.x = dragMaxX
}
drag.onMaximumYChanged: {
if (rect.y > dragMaxY)
rect.y = dragMaxY
}
}
}
}
}
| The Following User Says Thank You to elros34 For This Useful Post: | ||
|
|
2017-04-19
, 20:35
|
|
|
Posts: 433 |
Thanked: 727 times |
Joined on Oct 2012
@ Costa Blanca, España
|
#9
|
It's just a matter of download and install
| The Following User Says Thank You to Markkyboy For This Useful Post: | ||
|
|
2017-04-19
, 21:30
|
|
|
Posts: 433 |
Thanked: 727 times |
Joined on Oct 2012
@ Costa Blanca, España
|
#10
|
import QtQuick 2.0
import Sailfish.Silica 1.0
// y: Theme.paddingMedium
// x: (page.width - rect.width) /2
// Drag.active: dragArea.drag.active ??
Component.onCompleted: {
y = Theme.paddingMedium
x = (page.width - rect.width) /2
}
| The Following 2 Users Say Thank You to Markkyboy For This Useful Post: | ||
Currently, I have my draggable rectangle working in portrait mode, now how do I achieve this in landscape mode?, when I turn the phone, the rectangle is often 'off screen' either totally or a just a little, so how do I keep it on screen in landscape orientation as well as portrait?
Clearly, I want to keep my rectangle as draggable in both screen orientations, so the rectangle cannot be anchored...or can it?, I have tried with different positioning methods, but all prevent my rectangle from being draggable.
It would also be nice if my rectangle could have a 'starting' position, like screen center, but again, all attempts have failed because I want to keep the rectangle, draggable. Currently, the rectangle appears at the top left of my screen in portrait.
I looked at an app from coderus, that being ScreenTapShot2, for some 'mouse trick' clues, but I am still none the wiser, any ideas/input appreciated.
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..