Checkboxed isOn == true sets other checkboxes to disabled

Hi guys,

I’m having a little issue here I have two checkboxes with two different eventListeners, which when they are clicked on it sends a value over to myData.lua. Now when they are also clicked on they checked the value in myData.lua to see if its either true or false depending on weather one of the checkboxes have been clicked on but i also want it so that the checkbox that is checked can be unchecked still. I have this working to a degree the value gets set fine but I cannot get my checkboxes to become disabled they simply stay enabled. This is what my code looks like…

[lua]

–checkbox1

local function onSwitchPress1( event )

    local switch = event.target

    print( switch.id…" isOn to: "…tostring(switch.isOn) )

    if switch.isOn == true then

    myData.IRp1 = true

    print( myData.IRp1 )

    elseif switch.isOn == false then

    myData.IRp1 = false

    print( myData.IRp1 )

    elseif myData.IRp2 == true then

    switch.disabled = true

    elseif myData.IRp2 == false then

  switch.disabled = false

    end

end

local checkbox1 = widget.newSwitch

{

    left = 10,

    top = 300,

    style = “checkbox”,

    id = “checkbox1”,

    onPress = onSwitchPress1

}

checkbox1.disabled = false

sceneGroup:insert( checkbox1 )

–checkbox2

local function onSwitchPress2( event )

    local switch = event.target

    print( switch.id…" isOn to: "…tostring(switch.isOn) )

    if switch.isOn == true then

    myData.IRp2 = true

    print( myData.IRp2 )

    elseif switch.isOn == false then

    myData.IRp2 = false

    print( myData.IRp2 )

    elseif myData.IRp1 == true then

    switch.disabled = true

    elseif myData.IRp1 == false then

    switch.disabled = false

    end

end

local checkbox2 = widget.newSwitch

{

   left = 10,

   top = 350,

   style = “checkbox”,

   id = “checkbox2”,

   onPress = onSwitchPress2

}

checkbox2.disabled = false

sceneGroup:insert( checkbox2 )

[/lua]

Thanks again,

Matt.

Hi Matt,

You should carefully read the “fine print” about the different switch phases and the .isOn property. There are some details which may be throwing off your coding of this.

http://docs.coronalabs.com/api/library/widget/newSwitch.html

Best regards,

Brent

Hi Matt,

You should carefully read the “fine print” about the different switch phases and the .isOn property. There are some details which may be throwing off your coding of this.

http://docs.coronalabs.com/api/library/widget/newSwitch.html

Best regards,

Brent