Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

DragHandler acceptedButtons not limiting to that button



  • 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!



  • 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
                }
            }
        }

Log in to reply