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. DragHandler acceptedButtons not limiting to that button
Forum Updated to NodeBB v4.3 + New Features

DragHandler acceptedButtons not limiting to that button

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 354 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.
  • CyJoeC Offline
    CyJoeC Offline
    CyJoe
    wrote on last edited by
    #1

    Hi All,

    I am working on combining some touch screen and mouse gestures together in an application. I am looking at moving to use the new InputHandlers in Qt 5.12. I am attempting to use several DragHandlers where each one is specific to a mouse button. The documentation indicates that setting acceptedButtons: Qt.RightButton should limit the DragHandler to just right-mouse buttons, but I'm not seeing that. Is there another way to lock these down to a single mouse button?

    import QtQuick 2.12
    import QtQuick.Window 2.12
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        Rectangle {
            width: 200
            height: 200
            color: "red"
    
            DragHandler {
                acceptedButtons: Qt.RightButton
            }
        }
    }
    

    I have tested this on Mac and Windows using 5.12.0 and see the same behavior with this simple code, so I'm assuming I'm doing something wrong. TapHandler works fine.

    I'd appreciate any help. Thanks!

    1 Reply Last reply
    0
    • Shrinidhi UpadhyayaS Offline
      Shrinidhi UpadhyayaS Offline
      Shrinidhi Upadhyaya
      wrote on last edited by
      #2

      Hi @CyJoe , yeah you are correct,as you have already mentioned that the drag is not working properly in DragHandler,as it is working both with Left and Right Button, you can try the below code for just RightButton Dragging :-

      Rectangle {
          id: handle
              width: 200
              height: 200
              color: "red"
      
              MouseArea {
                  anchors.fill: parent
                  acceptedButtons: Qt.RightButton
      
                  drag {
                      target: handle
                  }
              }
          }
      

      Shrinidhi Upadhyaya.
      Upvote the answer(s) that helped you to solve the issue.

      1 Reply Last reply
      1

      • Login

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