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

Delayed initialization of dragging is not working properly

    XMLWordPrintable

Details

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

    Description

      Motivation: It may be necessary to activate DragHandler under a certain condition, or create dragging item dynamically and continue the gesture without the need to click again on the item containing DragHandler (This is partly related with https://bugreports.qt.io/browse/QTBUG-68075)

      With the example code:

      import QtQuick 2.13
      import QtQuick.Controls 2.13
      
      ApplicationWindow {
          id: root
          visible: true
          width: 640
          height: 480
      
          Rectangle {
              x: 130
              width: 200
              height: 200
              color: backgroundDragHandler.active ? "red" : "orange"
              opacity: 0.6
      
              DragHandler {
                  id: backgroundDragHandler
              }
          }
          Rectangle {
              y: 60
              width: 200
              height: 200
              color: tapHandler.pressed ? "red" : "green"
              opacity: 0.8
      
              TapHandler {
                  id: tapHandler
                  onLongPressed: {
                      console.debug("onLongPressed!")
                      if (dynamicallyCreation.checked) {
                          dynamicallyDragItemComponent.createObject(root);
                      }
                      else {
                          fordegroundDragHandler.enabled = true;
                      }
                  }
              }
              Label {
                  x: 160
                  y: 95
                  text: "1"
                  font.bold: true
                  font.pixelSize: 20
                  color: "black"
      
                  Rectangle {
                      anchors { fill: parent; margins: -10 }
                      color: "transparent"
                      border.color: "black"
                  }
              }
              Label {
                  x: 90
                  y: 20
                  text: "2"
                  font.bold: true
                  font.pixelSize: 20
                  color: "black"
      
                  Rectangle {
                      anchors { fill: parent; margins: -10 }
                      color: "transparent"
                      border.color: "black"
                  }
              }
              Label {
                  x: 160
                  y: 20
                  text: "3"
                  font.bold: true
                  font.pixelSize: 20
                  color: "black"
      
                  Rectangle {
                      anchors { fill: parent; margins: -10 }
                      color: "transparent"
                      border.color: "black"
                  }
              }
              Label {
                  x: 90
                  y: 95
                  text: "4"
                  font.bold: true
                  font.pixelSize: 20
                  color: "black"
      
                  Rectangle {
                      anchors { fill: parent; margins: -10 }
                      color: "transparent"
                      border.color: "black"
                  }
              }
          }
          Rectangle {
              x: 50
              y: 130
              width: 200
              height: 200
              color: fordegroundDragHandler.active ? "red" : "blue"
              opacity: 0.6
              visible: !dynamicallyCreation.checked
              enabled: !dynamicallyCreation.checked
      
              DragHandler {
                  id: fordegroundDragHandler
                  enabled: false
              }
              Label {
                  anchors.bottom: parent.bottom
                  text: "Drag enabled: %1".arg(fordegroundDragHandler.enabled)
              }
          }
          Component {
              id: dynamicallyDragItemComponent
      
              Rectangle {
                  x: 50
                  y: 130
                  width: 200
                  height: 200
                  color: fordegroundDragHandler.active ? "red" : "blue"
                  opacity: 0.6
      
                  DragHandler {
                      id: fordegroundDragHandler
                  }
              }
          }
      
          Switch {
              id: dynamicallyCreation
      
              anchors.bottom: parent.bottom
              text: "Dynamically creation of fordeground DragItem"
          }
      }
      
      

      You may notice several problems (you have to start the sample application again for each case).

      1. Steps to reproduce:

      • Press and hold on rectangle with number 1
      • Wait for longPress and activation of DragHandler (Drag enabled: 1)
      • Drag (without releasing the mouse button before that)

      or

      • Activate switch Dynamically creation of...
      • Press and hold on rectangle with number 1
      • Wait for creation of blue rectangle
      • Drag (without releasing the mouse button before that)

      Result:  Orange and not blue rectangle will be dragged

       

      2. Steps to reproduce:

      • Press and hold on rectangle with number 2
      • Drag in direction of rectangle with number 3

      or

      • Press and hold on rectangle with number 2
      • Wait for longPress and activation of DragHandler (Drag enabled: 1)
      • Drag in direction of rectangle with number 4

      or

      • Press and hold on rectangle with number 4
      • Wait for longPress and activation of DragHandler (Drag enabled: 1)
      • Drag blue reactangle  (without releasing the mouse button before that)

      or

      • Activate switch Dynamically creation of...
      • Press and hold on rectangle with number 4
      • Wait for creation of blue rectangle
      • Drag blue reactangle (without releasing the mouse button before that)

      Result:  Dragged rectangle (DragHandler target) skip with its top left corner to place where drag begins, instead of smoothly dragging.

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            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