Question

How can I disable Mouse Clicks in certain MouseAreas?

I am using the some code inside MouseArea{ .... } and want them to be disabled till the time a flag for them doesn't turn TRUE!

onClicked: {
                focus: true
                onClicked: pageLoader.source = "PAGE3.qml";
           }

There are multiple mouseAreas in the program. What is needed is to disable all other MouseAreas when one MouseArea has already been clicked and the page corresponding to that mouseArea is loaded using loader .
These mouseAreas are loaded as a matrix using the Grid function of QML.

How can I do that?

Was it helpful?

Solution 2

Got the answer! You need to add
enable: false

Example:
Grid {
enable: true }

This will enable the Grid and;

Grid {
enable: false }

This will disable the Grid!

OTHER TIPS

Something like this?

import QtQuick 2.1

Rectangle {
    width: 800
    height: 600
    property bool clickable
    MouseArea {
            anchors.fill:parent
            onClicked: {
                    if (clickable)
                            console.log("clicked");
                    else 
                            console.log("unclickable");

            }
    }
    Component.onCompleted: clickable = true;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top