Send press event to mouseArea from a parent QML
-
@J-Hilk
In fact I found the solution to correct the error message I got. But I'm still not capable to press the button by pressing the Arrow.the only thing I need now is to find a way to send press event to the mouse area.
I tried to change the "pressed" property of the mouse area but it is read only. And the pressed() function is not working without a MouseEvent.
-
@J-Hilk
In fact I found the solution to correct the error message I got. But I'm still not capable to press the button by pressing the Arrow.the only thing I need now is to find a way to send press event to the mouse area.
I tried to change the "pressed" property of the mouse area but it is read only. And the pressed() function is not working without a MouseEvent.
@DavidM29
well, A MouseArea needs aMouseEvent
to function. I don't know how one would emulate that.Why don't you defined your own signal in the root element of your customButton. Than chain the onPressed event from the mouse area to that signal. Also you should have no problem calling your own signal programatically.
-
I'm not sure to understand what this code do :
Does it call the onPressed event of the mouse area when the root.pressed() signal is emitted or does it emit the root.pressed() signal when I press the mouse area ?
I'm not sure to understand.
@DavidM29 said in Send press event to mouseArea from a parent QML:
I'm not sure to understand what this code do :
Does it call the onPressed event of the mouse area when the root.pressed() signal is emitted or does it emit the root.pressed() signal when I press the mouse area ?
I'm not sure to understand.
MouseArea pressed signal triggers the root item pressed signal
Item { id:root signal pressed() onPressed: console.log("root pressed signal"); MouseArea{ anchors.fill: parent onPressed: { console.log("MouseArea pressed signal"); root.pressed() } } }
-
@DavidM29 said in Send press event to mouseArea from a parent QML:
I'm not sure to understand what this code do :
Does it call the onPressed event of the mouse area when the root.pressed() signal is emitted or does it emit the root.pressed() signal when I press the mouse area ?
I'm not sure to understand.
MouseArea pressed signal triggers the root item pressed signal
Item { id:root signal pressed() onPressed: console.log("root pressed signal"); MouseArea{ anchors.fill: parent onPressed: { console.log("MouseArea pressed signal"); root.pressed() } } }
-
-
@J-Hilk
Do you have any idea how could I keep the color change on press of my button ? I tried to add a bool property that I change to true once I emit the root.pressed signal but I don't know how to change it back to false once I release the button.