Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. MultiPointTouchArea: onRelease called twice?
Forum Updated to NodeBB v4.3 + New Features

MultiPointTouchArea: onRelease called twice?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
multipointtouch
7 Posts 2 Posters 2.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TOMATO_QT
    wrote on last edited by TOMATO_QT
    #1

    I am playing with MultiPointTouchArea in a Canvas component to make a little drawing exercise. The code below works but the onReleased event is getting called twice and I don't understand why.

    From the log statements below, I see it gets called first with one TouchPoint, then again with two TouchPoints – the x and y positions are the same for all. Also the id of these touchPoints are undefined.

    I don't get it. Since I define a maximumTouchPoints and am testing with just one touch (I am testing this on my laptop using a trackpad, with just one "finger".) :

    • why am I getting multiple touchpoints
    • why is onReleased getting called twice?
    • why are the touchPoints id undefined, since I have defined my touchPoints?

    Log statements:

    qml: released 1 
    qml: 	 undefined 386.66015625 207.6640625
    qml: is this touch1? true
    
    qml: released 2
    qml: 	 undefined 386.66015625 207.6640625
    qml: is this touch1? true
    qml: 	 undefined 386.66015625 207.6640625
    qml: is this touch1? true
    

        import QtQuick 2.5
        import QtQuick.Controls 1.4
        
        ApplicationWindow {
            visible: true
            width: 640
            height: 480
            title: qsTr("Canvas")
        
            Canvas {
                id: canvas
                anchors.fill: parent
        
                property real lastX: 0
                property real lastY: 0
        
                onPaint: {
                    var ctx = getContext("2d")
                    ctx.lineWidth = 1
                    ctx.strokeStyle = "blue"
                    ctx.beginPath()
                    ctx.moveTo(lastX,lastY)
                    ctx.lineTo(touch1.x,touch1.y)
                    ctx.stroke()
        
                    canvas.lastX = touch1.x;
                    canvas.lastY = touch1.y;
                }
        
                function clearCanvas() {
                    var ctx = canvas.getContext("2d")
                     ctx.clearRect(0, 0, canvas.width, canvas.height)
                }
        
                MultiPointTouchArea {
                    anchors.fill: parent
                    minimumTouchPoints: 1
                    maximumTouchPoints: 1
                    touchPoints: [TouchPoint { id: touch1 }]
        
                    onPressed: {
                        canvas.lastX = touch1.x;
                        canvas.lastY = touch1.y;
        
                        canvas.clearCanvas();
                    }
        
                    onReleased: {
        
                        console.log("released", touchPoints.length); // CALLED TWICE?
        
                        var tp;
                        for (var i = 0; i < touchPoints.length; i++) {
                        tp = touchPoints[i];
                            console.log("\t",tp.id, tp.x, tp.y);
    
                            console.log("is this touch1?", tp === touch1);
                        }
                    }
        
                    onUpdated: canvas.requestPaint();
                }
            }
        }
    
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome again to devnet :)

      Looks strange indeed. What version of Qt and OS are you using ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome again to devnet :)

        Looks strange indeed. What version of Qt and OS are you using ?

        T Offline
        T Offline
        TOMATO_QT
        wrote on last edited by TOMATO_QT
        #3

        @SGaist

        Hi – using Qt 5.5.1 on OSX 10.11.12

        It doesn't seem like it should be doing this – but I am testing on the desktop, if that matters (why would it?).

        I noticed another anomaly:

        TouchPoint.previousX and TouchPoint.previousY are always 0 when running on the desktop but in the iOS simulator, they reprt accurate values. This seems like a bug – unless there is something really basic which I am missing.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Something to investigate, did you already check the bug report system ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          T 1 Reply Last reply
          0
          • SGaistS SGaist

            Something to investigate, did you already check the bug report system ?

            T Offline
            T Offline
            TOMATO_QT
            wrote on last edited by
            #5

            @SGaist

            The "two release events" issue has been reported and is open: https://bugreports.qt.io/browse/QTBUG-44781

            The "no "previousX, previousY" issue is there too: https://bugreports.qt.io/browse/QTBUG-41692

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You should vote for the bugs and add additional information if you can.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              T 1 Reply Last reply
              0
              • SGaistS SGaist

                You should vote for the bugs and add additional information if you can.

                T Offline
                T Offline
                TOMATO_QT
                wrote on last edited by
                #7

                @SGaist

                Yeah, I did. They have been open for a while now.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved