Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-78248

PointHandler stays active if it was short disabled

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.13.1
    • None
    • Dell XPS 15 9560, Windows 10
    • Windows

    Description

      Input Handlers have no direct way to cancel of the grabbing. Theoretically, you can use for this purpose:

      handler.enabled = false;
      handler.enabled = true;

      But the sample code shows that the handler remains active if it was only short disabled:

      import QtQuick 2.12
      import QtQuick.Controls 2.5
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
      
          Rectangle {
              id: glassPane
      
              anchors.fill: parent
              color: handler.enabled ? "green" : "grey"
      
              PointHandler {
                  id: handler
      
                  target: Rectangle {
                      parent: glassPane
                      color: "red"
                      visible: handler.active
                      x: handler.point.position.x - width / 2
                      y: handler.point.position.y - height / 2
                      width: 100; height: width; radius: width / 2
                  }
                  onEnabledChanged: {
                      console.debug("PointHandler ENABLED:", enabled);
                  }
              }
          }
      
          Timer {
              id: timer1
      
              running: true
              interval: 3000
              onTriggered: {
                  handler.enabled = false;
                  handler.enabled = true; //Comment this line and activate the next
                  //timer2.restart();
              }
          }
          Timer {
              id: timer2
      
              interval: 200 //Try other intervals: 0, 5, 10 etc.
              onTriggered: {
                  handler.enabled = true;
              }
          }
      }
      

      To see the problem, press and hold the mouse button (without and with mouse movement) until you see both logs.

      If you use a timer2 solution then whether the handler will switch to inactive is quite accidental. It depends on the interval of the timer2 and whether you move the mouse when timer2 was triggered.

      I think the problem affects all InputHandlers.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            srutledg Shawn Rutledge
            permotion88 Karol Polak
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes