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

DragHandler's grab permission CanTakeOverFromAnything does not respect keep grab

    XMLWordPrintable

Details

    • Windows
    • b09ce7dcd8ecf24ef23da8197a64e3fced3fc894 (qt/qtdeclarative/dev) 43c8d1b6f17540d2e5c82603662158251ce49944 (qt/qtdeclarative/6.1) 696d607d8596bd57e957a23778382d546196ef34 (qt/tqtc-qtdeclarative/5.15)

    Description

      I am not sure if this is a bug, but DragHandler with grabPermissions: CanTakeOverFromAnything will steal the grab from Item (ModalLayer) which is higher and has set keep touch and mouse grab. But perhaps this is the desired effect... Try it with following example code (You can drag orange rectangle):

       

      #include "ModalLayer.h"
      #include <QtDebug>
      
      ModalLayer::ModalLayer(QQuickItem* parent)
          : QQuickItem(parent) {
          this->setAcceptedMouseButtons(Qt::AllButtons);
          this->setAcceptTouchEvents(true);
          this->setKeepMouseGrab(true);
          this->setKeepTouchGrab(true);
      }
      
      bool ModalLayer::event(QEvent* event) {
          switch (event->type()) {
          case QEvent::KeyPress:
          case QEvent::MouseMove:
          case QEvent::MouseButtonPress:
          case QEvent::MouseButtonRelease:
          case QEvent::MouseTrackingChange:
          case QEvent::MouseButtonDblClick:
          case QEvent::Wheel:
          case QEvent::TouchBegin:
          case QEvent::TouchUpdate:
          case QEvent::TouchCancel:
          case QEvent::TouchEnd: {
              qDebug() << "BLOCK!" << event->type();
              return true;
          }
          default: break;
          }
          return QQuickItem::event(event);
      }
      
      
      import QtQuick 2.12
      import QtQuick.Controls 2.5
      
      import Ui 1.0
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
      
          Rectangle {
              anchors.fill: parent
              color: "grey"
      
              Rectangle {
                  x: 50
                  y: 50
                  width: 100
                  height: 100
                  color: "blue"
                  DragHandler { }
              }
      
              Rectangle {
                  x: 200
                  y: 200
                  width: 100
                  height: 100
                  color: "orange"
                  DragHandler {
                      grabPermissions: DragHandler.CanTakeOverFromAnything
                  }
              }
          }
          ModalLayer {
              anchors.fill: parent
      
              Rectangle {
                  anchors.fill: parent
                  color: "red"
                  opacity: 0.4
              }
          }
      }
      

       

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-78258
          # Subject Branch Project Status CR V

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes