Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. DragHandler::onDragChanged not reporting continously
Qt 6.11 is out! See what's new in the release blog

DragHandler::onDragChanged not reporting continously

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 484 Views 1 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.
  • K Offline
    K Offline
    kaixoo
    wrote last edited by kaixoo
    #1

    When performing a drag in a QML widget that captures events using a DragHandler, (click and move the mouse), the action is not registered until dragging is finished (unclick the mouse).
    Dragging should register intermediary movements (while you're moving the mouse).

    Video demonstrating this issue: https://gitlab.com/advanced-effects/Advanced-Effects/-/work_items/51#note_3556028185

    Relevant code:

            ApplicationCanvas {
                    DragHandler {
                            onGrabChanged: (transition, event) => appCanvas.onGrabChanged(transition, event)
                            onCanceled: (event) => appCanvas.onCanceled(event)
                    }
    

    Code receiving input: https://gitlab.com/advanced-effects/Advanced-Effects/-/blob/main/src/canvas/view/viewlayers/selection_viewlayer.cpp?ref_type=heads#L132

    void SelectionViewLayer::on_grab_changed(QPointingDevice::GrabTransition transition,
                                             QEventPoint event)
    {
            cancel_user_selection_area();
            if (toolCtx()->selectedTool != ToolIdentifier::selection) {
                    selectedObjects()->clear_all_objects();
                    return;
            };
    
            QRectF drag_area = interactable.get_normalized_drag_area(event);
    
            /* Middle man work .... */
    
            // Finally update selection area
            m_user_selection_area = drag_area;
            update_selected_objects(m_user_selection_area);
    };
    
    1 Reply Last reply
    0
    • K kaixoo

      Thanks! I see now that handlerPoint has no signals though, how am I supposed to signal when the position has changed?

      More generally, I'm also looking to register when the user clicks the middle mouse button + drags their mouse. DragHandler only registers events from the left click, is there a way I can generalize all this? Perhaps tracking the mouse position + the clicks separately? (HoverHandler + WheelHandler + Keys.onPressed?)

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote last edited by
      #6

      You're welcome!

      @kaixoo said in DragHandler::onDragChanged not reporting continously:

      I'm also looking to register when the user clicks the middle mouse button + drags their mouse. DragHandler only registers events from the left click

      Set your acceptedButtons: https://doc.qt.io/qt-6/qml-qtquick-draghandler.html#acceptedButtons-prop

      I see now that handlerPoint has no signals though, how am I supposed to signal when the position has changed?

      handlerPoint is a value type, like date or string. The string doesn't emit a signal either when a character gets modified. Rather, the whole value gets updated.

      Putting these together:

      DragHandler {
          acceptedButtons: Qt.MiddleButton
          onCentroidChanged: {
              if (active)
                  console.log("Centroid moved to", centroid.position)
          }
      }
      

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      1
      • GrecKoG Offline
        GrecKoG Offline
        GrecKo
        Qt Champions 2018
        wrote last edited by
        #2

        If you want to react to a drag move, you need a signal handler on the DragHandler's centroid.positionChanged.
        grabChanged is only emitted when starting or stopping a drag.

        1 Reply Last reply
        2
        • K Offline
          K Offline
          kaixoo
          wrote last edited by kaixoo
          #3

          Ohhh, I see. Thank you!
          Where is centroid documented btw? It's only mentioned 3 times in DragHandler's doc page and only with some code examples, without showing a reference for the full type.

          JKSHJ 1 Reply Last reply
          0
          • K kaixoo

            Ohhh, I see. Thank you!
            Where is centroid documented btw? It's only mentioned 3 times in DragHandler's doc page and only with some code examples, without showing a reference for the full type.

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote last edited by JKSH
            #4

            @kaixoo said in DragHandler::onDragChanged not reporting continously:

            Where is centroid documented btw? It's only mentioned 3 times in DragHandler's doc page and only with some code examples, without showing a reference for the full type.

            The full type is https://doc.qt.io/qt-6/qml-qtquick-handlerpoint.html

            centroid is inherited from MultiPointHandler: https://doc.qt.io/qt-6/qml-qtquick-multipointhandler.html#centroid-prop

            To navigate there from the DragHandler doc page, click on "List of all members, including inherited members" which goes to see https://doc.qt.io/qt-6/qml-qtquick-draghandler-members.html

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            1
            • K kaixoo has marked this topic as solved
            • K Offline
              K Offline
              kaixoo
              wrote last edited by
              #5

              Thanks! I see now that handlerPoint has no signals though, how am I supposed to signal when the position has changed?

              More generally, I'm also looking to register when the user clicks the middle mouse button + drags their mouse. DragHandler only registers events from the left click, is there a way I can generalize all this? Perhaps tracking the mouse position + the clicks separately? (HoverHandler + WheelHandler + Keys.onPressed?)

              JKSHJ 1 Reply Last reply
              0
              • K kaixoo

                Thanks! I see now that handlerPoint has no signals though, how am I supposed to signal when the position has changed?

                More generally, I'm also looking to register when the user clicks the middle mouse button + drags their mouse. DragHandler only registers events from the left click, is there a way I can generalize all this? Perhaps tracking the mouse position + the clicks separately? (HoverHandler + WheelHandler + Keys.onPressed?)

                JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote last edited by
                #6

                You're welcome!

                @kaixoo said in DragHandler::onDragChanged not reporting continously:

                I'm also looking to register when the user clicks the middle mouse button + drags their mouse. DragHandler only registers events from the left click

                Set your acceptedButtons: https://doc.qt.io/qt-6/qml-qtquick-draghandler.html#acceptedButtons-prop

                I see now that handlerPoint has no signals though, how am I supposed to signal when the position has changed?

                handlerPoint is a value type, like date or string. The string doesn't emit a signal either when a character gets modified. Rather, the whole value gets updated.

                Putting these together:

                DragHandler {
                    acceptedButtons: Qt.MiddleButton
                    onCentroidChanged: {
                        if (active)
                            console.log("Centroid moved to", centroid.position)
                    }
                }
                

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                1
                • K kaixoo has marked this topic as solved

                • Login

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