Problem with states when pressed
-
Hi,
I have created an app which have some custom buttons. I have created those buttons by using Image and MouseArea. Unfortunately I got problem with states I have a black rectangle on top of Image and I set opacity to 75% when you press mousearea. What is more those buttons are shown on flickable. The problem is when you click on the button and then start to flick the area, then sometimes the black rectangle stays visible even if I stop clicking on it. There is a port of code with Image:
@Image {
asynchronous: true
objectName: "ima"
id: ima
x: 0
y: 0
height: parent.height
width: parent.width
fillMode: Image.PreserveAspectFit
source: "light_off_button.png"
Rectangle{
id: ima_clicked
width: parent.width
height: parent.height
x: parent.width/18
y: x
color: "black"
visible: false
}states: State { when: icon.pressed PropertyChanges { target: mask; opacity: 0.75 } } MouseArea{ id: icon anchors.rightMargin: 0 x: 0 y: 0 height: parent.height width: parent.width onClicked: { action() } onCanceled: { mask.opacity=0 } } } OpacityMask{ id: mask width: ima.width height: ima.height opacity: 0 source: ima_clicked maskSource: ima }@
-
If i'm not mistaken, there is no code to make ima_clicked.visible == true. With this code it should be always invisible.
-
yeah I know, but it will make mask visible, I use it because my image has irregular shape
-
Which state is set when you release mouse?
-
When you release mouse this state
@states: State {
when: icon.pressed
PropertyChanges { target: mask; opacity: 0.75 }
}@
stops working because of when is not set to true, it works fine withour flickable. But with flickable area from time to time when i click a button it gets dark(state works) and move my finger a little bit signal about releasing it is not sent. I think its because flickable get the signals now.in 95% it works perfectly but there is this 5% that is annoying and I am not sure if my app freezed or its just this bug