Hi
I have a bunch of SimpleButtons that I’m converting over to MultiResolutionImage buttons. With the SimpleButtons, I had some logic to change the colour of the button (if the button was a vowel it would change the colour to distinguish from a consonant). It worked well. However when converting the code to use my button based on MIR, it’s not working, and I can’t see why.
Here’s the part that changes the colour (for the case of SimpleButton) & how I’m doing it by swapping an image of one colour for another of a different colour.
//SimpleButton { id: btnLetter1; width: 50; height: 50; color: LetterLogic.ifVowel(text) ? "#65A8DB" : "#C9A582"; onClicked: postpendLetter(text) }
MyButton { id: btnLetter1; buttonName: LetterLogic.ifVowel(text) ? "btnVowel" : "btnConsonant"; onClicked: postpendLetter(text) }
Here’s the MyButton qml
import QtQuick 1.1
import VPlay 1.0
Item {
id: button
width: btnUpImg.width
height: btnUpImg.height
property alias text: buttonText.text
property alias textColor: buttonText.color
property alias textSize: buttonText.font.pixelSize
property string buttonName
signal clicked
MultiResolutionImage {
id: btnUpImg
source: "img/" + buttonName + "-up.png"
anchors.centerIn: parent
visible: !ma.pressed
}
MultiResolutionImage {
id: btnDownImg
source: "img/" + buttonName + "-down.png"
anchors.centerIn: parent
visible: ma.pressed
}
Text {
id: buttonText
anchors.centerIn: btnUpImg
font.pixelSize: 14
color: "white"
}
MouseArea {
id: ma
anchors.fill: btnUpImg
onClicked: button.clicked()
}
}
My JS tester function worked well in the SimpleButton case to change the colour dynamically, but this same logic is failing to achieve the same outcome in the MIR image case. BTW this is why I asked before if tinting was working, as if it was, I may be able to apply the same SimpleButton colour-changing concept to the image version.
This issue is kinda driving me crazy, so any tips are gratefully welcome. I’m kinda guessing the source: in MIR can’t be updated after it’s established, like a color can be for SimpleButton.
Thanks.
Cheers, Michael.