numberCruncher
numberCruncher

Reputation: 645

Extend MouseArea beyond component

I have a Rectangle with width 1 (a line), which should be draggable:

Rectangle {
    id: recMark
    border.width: 0
    width: 1
    height: parent.height
    y: 0
    color: "red"
    opacity: 0.3
    visible: true
    MouseArea {
        anchors.fill: parent
        drag.target: recMark
        drag.axis: Drag.XAxis

    }
}

Is it possible to extend the mouse area beyond the rectangle, e.g. 3 pixels around it? Obviously it would be hard to hit the right pixel with the mouse.

Upvotes: 1

Views: 285

Answers (1)

augre
augre

Reputation: 2051

You can add negative margins to the MouseArea:

MouseArea {
    anchors.fill: parent
    anchors.margins: -3
    // ...
}

Upvotes: 4

Related Questions