Consider following code. It’s very simple: create a scrollview & put a segmented control on it:
local widget=require("widget") local function onSegmentSwitch(event) local target = event.target print( "Segment Label is:", target.segmentLabel ) print( "Segment Number is:", target.segmentNumber ) end mScrollView = widget.newScrollView { top = 0, left = 0, width = display.contentWidth, height = display.contentHeight , hideBackground = true, --listener = scrollListener, --hideScrollBar = true, } local segmentedControl = widget.newSegmentedControl { top = 100, left = 100, segments = { "1", "2", "3", "4", "5"}, segmentWidth = 40, defaultSegment = 3, onPress = onSegmentSwitch, } mScrollView:insert(segmentedControl)
And from my testing, it’s not working! When I click on the segmented control buttons, nothing happens.
If I comment out the last line,
-- mScrollView:insert(segmentedControl)
It works then. (Of course)
Am I doing anything wrong here?
P.S. I am using daily build 2108.