Issue with Segmented Control

Hi,

This is the first time I have used a segmented control or image sheets,  so I am not sure if I am doing things correct.  The following code works basically OK (registers presses correctly and 75% of graphics are in the correct place) except  the middle segment is graphically always selected (selected sprite is always showing) and the text is blue.  Any advice or help greatly appreciated.

[lua]

local function onPress( event )

    local target = event.target

    print( “Segment Label is:”, target.segmentLabel )

    print( “Segment Number is:”, target.segmentNumber )

end

local options =

    {

        width = 190,

        height = 61,

        numFrames = 6,

        sheetContentWidth = 570,  --width of original 1x size of entire sheet

        sheetContentHeight = 122  --height of original 1x size of entire sheet

    }

local imageSheet = graphics.newImageSheet( “Assets/sb_SearchResults/filterBarSheet.png”, options )

local segmentedControl = widget.newSegmentedControl

    {

        left = 50,

        top = header.height,

        width = 190,

        height = 61,

        sheet = imageSheet,

        leftSegmentFrame = 1,

        leftSegmentSelectedFrame = 4, 

        middleSegmentFrame = 2, 

        middleSegmentSelectedFrame = 5,

        rightSegmentFrame = 3, 

        rightSegmentSelectedFrame = 6,

        --dividerFrame = 6,

        segmentWidth = 190,

        labelSize = 24,

        segments = { “Common”, “Latin”, “Family” },

        defaultSegment = 3,

        onPress = onPress,

    }

myGroup:insert(segmentedControl)

[/lua]

Hi @cbriggsnz,

At a first look, do the image sheet specs add up correctly? I see 6 frames of 190 wide, but a total of 570 sheet width. I’m not sure your scaling setup, but I would think it should be 3 frames of 190, or 6 frames of 95? Same thing on the height.

Best regards,

Brent

Thanks Brent,

I haven’t gotten into scaling yet,  so that was a mistake on my part.  I have removed a couple of lines.  My imageSheet is 1140 x 61 and contains six images teach 190 x 61 - I still appear to have the same issue - middleSegmentSelectedFrame is displayed all the time (and the unselected segment text is blue).

[lua]

    local options =

    {

        width = 190,

        height = 61,

        numFrames = 6

    }

[/lua]

Thanks

Same issue here. Middle button always selected.

[lua]

local options =

{

    – The params below are required

    width = 200,

    height = 80,

    numFrames = 2,

    – The params below are optional; used for dynamic resolution support

    sheetContentWidth = 400,  – width of original 1x size of entire sheet

    sheetContentHeight = 80  – height of original 1x size of entire sheet

}

local imageSheet = graphics.newImageSheet( “pics/sheet_btn.png”, options )

    

– Listen for segmented control events

local function onPress( event )

    local target = event.target

    print( “Segment Label is:”, target.segmentLabel )

    print( “Segment Number is:”, target.segmentNumber )

end

– Create a default segmented control (using widget.setTheme)

local segmentedControl = widget.newSegmentedControl

{

    left = 50,

    top = 150,

    width = 200,

    height = 80,

    sheet = imageSheet,

    leftSegmentFrame = 1,

    leftSegmentSelectedFrame = 2, 

    middleSegmentFrame = 1, 

    middleSegmentSelectedFrame = 2,

    rightSegmentFrame = 1, 

    rightSegmentSelectedFrame = 2,

    segmentWidth = 200,

    segments = { “Hello”, “Corona”, “SDK!” },

    defaultSegment = 1,

    onPress = onPress,

}

  

[/lua]

Hope it can be fixed.

Hi guys,

Could one of you please post a bug report with the assets you’re using for customization and a quick example?

Thanks,

alex

Hi @cbriggsnz,

At a first look, do the image sheet specs add up correctly? I see 6 frames of 190 wide, but a total of 570 sheet width. I’m not sure your scaling setup, but I would think it should be 3 frames of 190, or 6 frames of 95? Same thing on the height.

Best regards,

Brent

Thanks Brent,

I haven’t gotten into scaling yet,  so that was a mistake on my part.  I have removed a couple of lines.  My imageSheet is 1140 x 61 and contains six images teach 190 x 61 - I still appear to have the same issue - middleSegmentSelectedFrame is displayed all the time (and the unselected segment text is blue).

[lua]

    local options =

    {

        width = 190,

        height = 61,

        numFrames = 6

    }

[/lua]

Thanks

Same issue here. Middle button always selected.

[lua]

local options =

{

    – The params below are required

    width = 200,

    height = 80,

    numFrames = 2,

    – The params below are optional; used for dynamic resolution support

    sheetContentWidth = 400,  – width of original 1x size of entire sheet

    sheetContentHeight = 80  – height of original 1x size of entire sheet

}

local imageSheet = graphics.newImageSheet( “pics/sheet_btn.png”, options )

    

– Listen for segmented control events

local function onPress( event )

    local target = event.target

    print( “Segment Label is:”, target.segmentLabel )

    print( “Segment Number is:”, target.segmentNumber )

end

– Create a default segmented control (using widget.setTheme)

local segmentedControl = widget.newSegmentedControl

{

    left = 50,

    top = 150,

    width = 200,

    height = 80,

    sheet = imageSheet,

    leftSegmentFrame = 1,

    leftSegmentSelectedFrame = 2, 

    middleSegmentFrame = 1, 

    middleSegmentSelectedFrame = 2,

    rightSegmentFrame = 1, 

    rightSegmentSelectedFrame = 2,

    segmentWidth = 200,

    segments = { “Hello”, “Corona”, “SDK!” },

    defaultSegment = 1,

    onPress = onPress,

}

  

[/lua]

Hope it can be fixed.

Hi guys,

Could one of you please post a bug report with the assets you’re using for customization and a quick example?

Thanks,

alex

Did anybody get this resolved, I have the same issue

@cublah: could you post a bug report with a sample project including custom assets? I’ll look at it if i have a report.

Thanks,

alex

ok, not sure how to post a bug report but here’s a sample project 

https://www.dropbox.com/s/lc37roa15v6vmfp/test.zip?dl=0

It seems to be a problem when initially setting the selected segment to 1 and when going from a middle segment to the 1st segment.

Chris

Also the labelColor doesn’t work correctly either, it ignores the over values and is always white.

Allright, i got the project and i’ll post a bug on this.

Thanks!

alex

Any news on this?

I need to use this control for a deadline I have for a client, if it can’t be fixed I have to find a way around it (maybe just using buttons)

I would go for a button-based implementation for now. The fix will be there soon, i can’t estimate a precise date however.

Thanks,

alex

Did anybody get this resolved, I have the same issue

@cublah: could you post a bug report with a sample project including custom assets? I’ll look at it if i have a report.

Thanks,

alex

ok, not sure how to post a bug report but here’s a sample project 

https://www.dropbox.com/s/lc37roa15v6vmfp/test.zip?dl=0

It seems to be a problem when initially setting the selected segment to 1 and when going from a middle segment to the 1st segment.

Chris

Also the labelColor doesn’t work correctly either, it ignores the over values and is always white.