myWallJSON
myWallJSON

Reputation: 9522

QML: how to get a direction of Mouse movement on top of MouseAeria without actually moving any visiable component?

I wonder if there is a way to send to some function like utilety.move some variables like (newX, newY) that would represent where to the mouse have moved alike something like such pseudocode

each time event calls function
var coord =  - initioal mouse coords + current mouse coords
utilety.move(coord )
initioal mouse coords  = current mouse coords

So to controll movment of QML element not using Drag target but own method (probable C++ one)

Upvotes: 1

Views: 1632

Answers (2)

Pavel Osipov
Pavel Osipov

Reputation: 2097

If you developing for mobile platform you may consider for Qt Quick Gestures plugin:

import Qt.labs.gestures 2.0
GestureArea {
    Tap: {
        when: gesture.hotspot.x > gesture.hotspot.y
        onStarted: console.log("tap in upper right started")
        onFinished: console.log("tap in upper right completed")
    }
}

Look here for more info: http://labs.qt.nokia.com/2010/10/05/getting-in-touch-with-qt-quick-gestures-and-qml/

Upvotes: 1

Kunal
Kunal

Reputation: 3535

I don't understand your question clearly, but looks like you want to have mouse cordinate in QML.

if that is case then, you can use MouseArea element, it has mouseX and mouseY property which you can use to locate mouse cursor.

and onPositionChanged handler is called when mouse position is changed.

MouseArea {
     anchors.fill: parent
     onPositionChanged: { 
      //var curMouseX = mouseX 
      //var curMouseY = mouseY 
     }
}

Upvotes: 1

Related Questions