Problems with widget.newSwitch()

I have two problems with the newSwitch widget

  1. I’m using the style “onOff”.

Concerning to the documentation http://docs.coronalabs.com/api/library/widget/newSwitch.html I should be able to use onPress, onRelease or onEvent.

The only way to get the event callback fired is using onPress.

Is this the way it’s supposed to be ?

  1. In the eventHandler of onPress I set the state of onOff-switch using

    switch:setState({isOn=false})

Unfortunately it’s switches to a mixed state. The switch goes to the “off” position but keeps the “on”-color.

See third row of screenshot (on - off - mixed/broken ).

How can I avoid this ?

No, solution for this ?

Is this a bug or am I making anything wrong ?

Is there a reason you’re doing this instead of letting the switch manage it’s own state?

In my app I have a number off options/vcategories you can switch on/off but you’re only allowed to select/activate four of them.

So in the eventHandler I check the number of (activated/checked) options and if it exceeds four I display an alert and set the (last) selected switch programmatically to off/false.

I found no other way to intercept/exit the event (like event.preventDefault() in jQuery) so the switch will never change state.

If there’s a better solutions I’m curious to know it.

Thanks

Maybe try putting it in a timer for say 10ms  later after the dialog gets dismissed…

Rob

No, solution for this ?

Is this a bug or am I making anything wrong ?

Is there a reason you’re doing this instead of letting the switch manage it’s own state?

In my app I have a number off options/vcategories you can switch on/off but you’re only allowed to select/activate four of them.

So in the eventHandler I check the number of (activated/checked) options and if it exceeds four I display an alert and set the (last) selected switch programmatically to off/false.

I found no other way to intercept/exit the event (like event.preventDefault() in jQuery) so the switch will never change state.

If there’s a better solutions I’m curious to know it.

Thanks

Maybe try putting it in a timer for say 10ms  later after the dialog gets dismissed…

Rob