widget switch changes position

Yup. Not using them until they’re fixed. If you don’t mind mixing libraries then you can try the switch in widgetCandy. I hope CL fixes this one and other widget bugs soon. We sure have been waiting for a real long time. 

I haven’t run into this but based on the description, isn’t the workaround to change the X position if the switch is isOn? So like this:

 if autoUpdateSwitch.isOn and switchFix then autoUpdateSwitch.x = autoUpdateSwitch.x + 5 end

I stuck a local switchFix = true flag at the top of the code, that way when the bug is fixed you’d only have to change that flag (although just ditching those three lines for each switch isn’t that big of a deal).

Jay

Good idea but the horizontal movement occurs in both state changes and I think the amount of movement is not fixed but scaled based on resolution and device etc. You could probably get it to work but in all reality its probably not going to be a lasting solution.

Tom from CoronaLabs support has just sent me a message regarding my bug report and he says that the bug fix will be in an upcoming daily build. 

If this is not an auto-generated message then the bug might be fixed soon :wink:

I don’t think its an auto-generated message as I have many reported widget bugs which never got acknowledged let alone a promised fix. So this message from Tom must be written on purpose which is great news. Then again, “fixed in an upcoming daily build” could mean tomorrow or next year. Will believe it when I see it fixed. Thanks for sharing in any case.

This is his original message:

"Hello,

We are aware of the issue and should have it fixed in daily builds shorty. Thanks for submitting the bug.

Regards,
Tom"

But yeah, I think they are actively working on the widget library :wink:

I don’t want to get your thread “contentious” and cause it to get locked so I will say no more!  :slight_smile:

1,5 Years later and the switch is still moving.

I’m experiencing issues with this when trying to customize my on off switch.

[lua]function M.newOnOffSwitch( parent, x, y, id, onPressEvent, switchState )
local onOffSwitchSheet = M.newComplexImageSheet( ‘images/widgets/onoff_switch/OnOffSwitch.png’, {
{ x = 0, y = 0, width = 64, height = 44 },
{ x = 1, y = 45, width = 42, height = 42 },
{ x = 45, y = 44, width = 64, height = 44 }},
117, – Image sheet Width
88 – Image sheet height
)
local onOffSwitch = widget.newSwitch {
id = id,
initialSwitchState = switchState or false,
onPress = onPressEvent,
sheet = onOffSwitchSheet,
onOffBackgroundFrame = 1,
onOffBackgroundWidth = 72,
onOffBackgroundHeight = 44,
onOffMask = ‘images/widgets/onoff_switch/OnOffSwitchMask.png’,
onOffHandleDefaultFrame = 2,
onOffHandleOverFrame = 2,
onOffOverlayFrame = 3,
onOffOverlayWidth = 64,
onOffOverlayHeight = 44
}
onOffSwitch:translate( x, y )
parent:insert( onOffSwitch )
return onOffSwitch
end[/lua]

There doesn’t seem to be a problem when using the default switch, but I’d still like to be able to use my own custom images.  :frowning:

Hi @jjsanchezramirez,

Can you post your image sheet so we can inspect how you’ve set it up in relation to the switch parts? Images can be uploaded by clicking the “More Reply Options” button below the response box, and on the next page you’ll see options to attach and upload an image.

Thanks,

Brent

Yes, of course.

Hi @jjsanchezramirez,

At a glance, there are various issues with your image sheet. Sizes in the code don’t match sizes on the sheet, and the overall setup doesn’t follow the guide on visually customizing an on-off switch:

https://docs.coronalabs.com/api/library/widget/newSwitch.html#visual-customization

Please read through all of the details there, set up your image sheet properly, and the switch should be fine.

Best regards,

Brent

1,5 Years later and the switch is still moving.

I’m experiencing issues with this when trying to customize my on off switch.

[lua]function M.newOnOffSwitch( parent, x, y, id, onPressEvent, switchState )
local onOffSwitchSheet = M.newComplexImageSheet( ‘images/widgets/onoff_switch/OnOffSwitch.png’, {
{ x = 0, y = 0, width = 64, height = 44 },
{ x = 1, y = 45, width = 42, height = 42 },
{ x = 45, y = 44, width = 64, height = 44 }},
117, – Image sheet Width
88 – Image sheet height
)
local onOffSwitch = widget.newSwitch {
id = id,
initialSwitchState = switchState or false,
onPress = onPressEvent,
sheet = onOffSwitchSheet,
onOffBackgroundFrame = 1,
onOffBackgroundWidth = 72,
onOffBackgroundHeight = 44,
onOffMask = ‘images/widgets/onoff_switch/OnOffSwitchMask.png’,
onOffHandleDefaultFrame = 2,
onOffHandleOverFrame = 2,
onOffOverlayFrame = 3,
onOffOverlayWidth = 64,
onOffOverlayHeight = 44
}
onOffSwitch:translate( x, y )
parent:insert( onOffSwitch )
return onOffSwitch
end[/lua]

There doesn’t seem to be a problem when using the default switch, but I’d still like to be able to use my own custom images.  :frowning:

Hi @jjsanchezramirez,

Can you post your image sheet so we can inspect how you’ve set it up in relation to the switch parts? Images can be uploaded by clicking the “More Reply Options” button below the response box, and on the next page you’ll see options to attach and upload an image.

Thanks,

Brent

Yes, of course.

Hi @jjsanchezramirez,

At a glance, there are various issues with your image sheet. Sizes in the code don’t match sizes on the sheet, and the overall setup doesn’t follow the guide on visually customizing an on-off switch:

https://docs.coronalabs.com/api/library/widget/newSwitch.html#visual-customization

Please read through all of the details there, set up your image sheet properly, and the switch should be fine.

Best regards,

Brent