Best Practices for segmentControl

Hi buddy,

Is there any best practices for working with the Segmented Control? I find its behavior is a bit confusing:

  • If I set the x value of it by calculation (e.g.  display.width/3), it doesn’t respond to the onPress event;

  • If I use the setReferencePoint method after it is added into the scene’s view, it doesn’t respond to the onPress event;

  • Even set the x value by specifying explicitly a number, it seems sometimes it might stop responding to the onPress event, subject to the number of segments I define.

local viewSwitch = widget.newSegmentedControl

    {

        --left = display.contentWidth/2,  <-------- cannot do that        

        segments = { “a”, “b”, “c”, “d”},

       defaultSegment = 1,

        onPress = viewSwitchPressed

    }

group:insert(viewSwitch )

viewSwitch:setReferencePoint(display.CenterReferencePoint) <------------- weird thing happens if do that

viewSwitch.x = 120 <------- sometime works sometimes not

Can any guru out there give me some advices?

Cheers,

Jimmy

If I position the control at the top right corner, the onPress event only fires if I click the segment 1, no response from segment 2 at all.

I got no idea what’s wrong with it, anyone please give me some help.

Jimmy 

corona.png

What version of Corona SDK are you running?

2013.1076

I believe you have found a bug.  Can you do a very small sample project that creates the segment controller and file a bug report with “Report a Bug” above.

Thanks

Rob

Bug report submitted.

Due to this bug I need to considerably modify the screen design, please fix the bug ASAP, if the control only works at certain screen position only, it’s just useless.

Regards,

Jimmy

I am having the same problem.  Depending on where the widget is placed, only one of the segments generates an onPress event.  

The bug occurs when the widget has 3 or more segments.

Thanks

Bill

I think I hit the same problem.

Try this following simple main.lua

Just start a blank project, copy and paste the following lines of code into it, and run.

You will see that you CANNOT select the LAST segment when it is position on certain position of the screen.

I am using version 2013.1076

Please fix this as soon as possible, otherwise we cannot use them in projects at all.

Thanks

Jim

----------- CODE FOLLOWS

local widget = require(“widget”)

– sc1 works fine

local sc1 = widget.newSegmentedControl{ left = 30, top = 30,

        segments = { “Opt 1”, “Opt 2” },

        defaultSegment = 1}

– sc2 works fine

local sc2 = widget.newSegmentedControl{ left = 60, top = 70,

        segments = { “Opt 1”, “Opt 2” },

        defaultSegment = 1}

– sc3 - CANNOT select “Opt 2”

local sc3 = widget.newSegmentedControl{ left = 90, top = 110,

        segments = { “Opt 1”, “Opt 2” },

        defaultSegment = 1}

– sc11 works fine

local sc11 = widget.newSegmentedControl{ left = 30, top = 210,

        segments = { “Opt 1”, “Opt 2”, “Opt 3”, “Opt 4”, “Opt 5” },

        defaultSegment = 1}

– sc12 - CANNOT select “Opt 5”

local sc12 = widget.newSegmentedControl{ left = 60, top = 250,

        segments = { “Opt 1”, “Opt 2”, “Opt 3”, “Opt 4”, “Opt 5” },

        defaultSegment = 1}

Do you have the bug #?

The number I got for this bug is 22868

The engineers are looking into it.

If I position the control at the top right corner, the onPress event only fires if I click the segment 1, no response from segment 2 at all.

I got no idea what’s wrong with it, anyone please give me some help.

Jimmy 

corona.png

What version of Corona SDK are you running?

2013.1076

I believe you have found a bug.  Can you do a very small sample project that creates the segment controller and file a bug report with “Report a Bug” above.

Thanks

Rob

Bug report submitted.

Due to this bug I need to considerably modify the screen design, please fix the bug ASAP, if the control only works at certain screen position only, it’s just useless.

Regards,

Jimmy

I am having the same problem.  Depending on where the widget is placed, only one of the segments generates an onPress event.  

The bug occurs when the widget has 3 or more segments.

Thanks

Bill

I think I hit the same problem.

Try this following simple main.lua

Just start a blank project, copy and paste the following lines of code into it, and run.

You will see that you CANNOT select the LAST segment when it is position on certain position of the screen.

I am using version 2013.1076

Please fix this as soon as possible, otherwise we cannot use them in projects at all.

Thanks

Jim

----------- CODE FOLLOWS

local widget = require(“widget”)

– sc1 works fine

local sc1 = widget.newSegmentedControl{ left = 30, top = 30,

        segments = { “Opt 1”, “Opt 2” },

        defaultSegment = 1}

– sc2 works fine

local sc2 = widget.newSegmentedControl{ left = 60, top = 70,

        segments = { “Opt 1”, “Opt 2” },

        defaultSegment = 1}

– sc3 - CANNOT select “Opt 2”

local sc3 = widget.newSegmentedControl{ left = 90, top = 110,

        segments = { “Opt 1”, “Opt 2” },

        defaultSegment = 1}

– sc11 works fine

local sc11 = widget.newSegmentedControl{ left = 30, top = 210,

        segments = { “Opt 1”, “Opt 2”, “Opt 3”, “Opt 4”, “Opt 5” },

        defaultSegment = 1}

– sc12 - CANNOT select “Opt 5”

local sc12 = widget.newSegmentedControl{ left = 60, top = 250,

        segments = { “Opt 1”, “Opt 2”, “Opt 3”, “Opt 4”, “Opt 5” },

        defaultSegment = 1}

Do you have the bug #?

The number I got for this bug is 22868