I have an issue with an App I have been working on.
I have a row of switches which enable people to choose various items. Problem is only the first switch works.
This is the code to place the switches into the group.
In this instance the ‘Small’ switch will change states, but the ‘Regular’ and ‘Large’ switches do not change states or even register a press.
I recently updated to Graphics 2.0 and previous to the upgrade all the switches worked correctly.
I hope someone can help me with this problem. I am sure I am missing something really obvious.
-- create size - SmallsizeSmallText = display.newEmbossedText( "Small", 0, 0, myData.menuFont, 20 ) sizeSmallText.anchorX, sizeSmallText.anchorY = 0, .5 sizeSmallText:setFillColor( 255/255 ) sizeSmallText.x = sizeText.x + 55 sizeSmallText.y = sizeText.y + 2 sizeSmallText.alpha = 0 widgetGroup:insert(sizeSmallText) checkBoxSmall = widget.newSwitch { left = 100, top = sizeText.y - 20, style = "checkbox", id = "Small", initialSwitchState = false, onPress = onSizePress, } checkBoxSmall.alpha = 0 widgetGroup:insert(checkBoxSmall) -- create size - regular sizeRegularText = display.newEmbossedText( "Regular", 0, 0, myData.menuFont, 20 ) sizeRegularText.anchorX, sizeRegularText.anchorY = 0, 0.5 sizeRegularText:setFillColor( 255/255 ) sizeRegularText.x = sizeText.x + 135 sizeRegularText.y = sizeText.y + 2 sizeRegularText.alpha = 0 widgetGroup:insert(sizeRegularText) checkBoxRegular = widget.newSwitch { left = 190, top = sizeText.y - 20, style = "checkbox", id = "Regular", initialSwitchState = false, onPress = onSizePress, } checkBoxRegular.alpha = 0 widgetGroup:insert(checkBoxRegular) -- create size - Large sizeLargeText = display.newEmbossedText( "X-Lrg", 0, 0, myData.menuFont, 20 ) sizeLargeText.anchorX, sizeLargeText.anchorY = 0, .5 sizeLargeText:setFillColor( 255/255 ) sizeLargeText.x = sizeText.x + 220 sizeLargeText.y = sizeText.y + 2 sizeLargeText.alpha = 0 widgetGroup:insert(sizeLargeText) checkBoxLarge = widget.newSwitch { left = 270, top = sizeText.y - 20, style = "checkbox", id = "Large", initialSwitchState = false, onPress = onSizePress } checkBoxLarge.alpha = 0 widgetGroup:insert(checkBoxLarge)
This is code to transition them in (there are more switches, but the code is the same for all of them.):
--Transition out the list, transition in the item selected text and the back button transition.to( list, { x = - list.contentWidth, time = 400, transition = easing.Quad } ) --transition.to( itemSelected, { x = display.contentCenterX,y = 60, time = 0, transition = easing.outExpo } ) transition.to( backButton, { alpha = 1.0, time = 400, transition = easing.outExpo } ) transition.to( menuButton, { alpha = 0, time = 400, transition = easing.outExpo } ) transition.to( sizeText, { alpha = sizeTextOption, time = 400, transition = easing.outExpo } ) transition.to( sizeSmallText, { alpha = sizeTextOption, time = 400, transition = easing.outExpo } ) transition.to( checkBoxSmall, { alpha = sizeSmallOption, time = 400, transition = easing.outExpo } ) transition.to( sizeRegularText, { alpha = sizeRegularOption, time = 400, transition = easing.outExpo } ) transition.to( checkBoxRegular, { alpha = sizeRegularOption, time = 400, transition = easing.outExpo } ) transition.to( sizeLargeText, { alpha = sizeLargeOption, time = 400, transition = easing.outExpo } ) transition.to( checkBoxLarge, { alpha = sizeLargeOption, time = 400, transition = easing.outExpo } )