[Resolved] Override Switch OnOff style

Hi,

is there a practical example that shows how to customize the switch widget through the following parameters?

onOffBackgroundFrame

onOffBackgroundWidth, onOffBackgroundHeight

onOffOverlayWidth, onOffOverlayHeight

onOffOverlayFrame

onOffHandleDefaultFrame

onOffHandleOverFrame

onOffMask

Thanks in advance.

Best regards.

-j

As we should always do, we have to study, study and … learn.

I solved the problem by myself…

 -- Override style newSwitch widget local options = { --array of tables representing each frame (required) frames = { -- FRAME 1: onOffBackgroundFrame { x = 0, y = 0, width = 160, height = 24 }, -- FRAME 2: onOffHandleDefaultFrame { x = 0, y = 24, width = 48, height = 25 }, -- FRAME 3: onOffHandleOverFrame { x = 48, y = 24, width = 48, height = 25 }, -- FRAME 4: onOffOverlayFrame { x = 0, y = 49, width = 104, height = 31 }, }, --optional parameters; used for dynamic resolution support sheetContentWidth = 160, sheetContentHeight = 80 } local onOffSwitchSheet = graphics.newImageSheet( "switch/onOffSwitchSheet.png", options ) local onOffSwitch = widget.newSwitch { left = 190, top = 180, sheet = onOffSwitchSheet, onOffBackgroundFrame = 1, onOffBackgroundWidth = 160, onOffBackgroundHeight = 24, onOffHandleDefaultFrame = 2, onOffHandleOverFrame = 3, onOffOverlayFrame = 4, onOffOverlayWidth = 104, onOffOverlayHeight = 31, onOffMask = "switch/onOffMask.png", initialSwitchState = true, onPress = onOffSwitchListener, onRelease = onOffSwitchListener, } 

In attach resource files (make with Inkscape).

Regards

-j

As we should always do, we have to study, study and … learn.

I solved the problem by myself…

 -- Override style newSwitch widget local options = { --array of tables representing each frame (required) frames = { -- FRAME 1: onOffBackgroundFrame { x = 0, y = 0, width = 160, height = 24 }, -- FRAME 2: onOffHandleDefaultFrame { x = 0, y = 24, width = 48, height = 25 }, -- FRAME 3: onOffHandleOverFrame { x = 48, y = 24, width = 48, height = 25 }, -- FRAME 4: onOffOverlayFrame { x = 0, y = 49, width = 104, height = 31 }, }, --optional parameters; used for dynamic resolution support sheetContentWidth = 160, sheetContentHeight = 80 } local onOffSwitchSheet = graphics.newImageSheet( "switch/onOffSwitchSheet.png", options ) local onOffSwitch = widget.newSwitch { left = 190, top = 180, sheet = onOffSwitchSheet, onOffBackgroundFrame = 1, onOffBackgroundWidth = 160, onOffBackgroundHeight = 24, onOffHandleDefaultFrame = 2, onOffHandleOverFrame = 3, onOffOverlayFrame = 4, onOffOverlayWidth = 104, onOffOverlayHeight = 31, onOffMask = "switch/onOffMask.png", initialSwitchState = true, onPress = onOffSwitchListener, onRelease = onOffSwitchListener, } 

In attach resource files (make with Inkscape).

Regards

-j