PDA

View Full Version : Swich Control - How to get True or false?



Mathan
10th October 2016, 11:29
Hi,

I want to get switch state like true or false, Am I doing this right?

Code snippet:


Switch {
id: idswitch
checked: false
onCheckedChanged: {
console.log("Switch");
if (idswitch.state == "on")
{
console.log("toggle - True");
}

if (idswitch.state === true)
{
console.log("toggle - True");
}

}
}

Anything else to add, like


states: [
State { name: "state1"; when: sharedCondition },
State { name: "state2"; when: sharedCondition }
]

anda_skoa
10th October 2016, 12:17
So you are checking for a state name "on" but your states are called "state1" and "state2"?
Did you set the state property somewhere and expect to be "on"?

Cheers,
_

P.S.: [code] tags and sensible identation would be great