Hi All,
I am seeing a similar sort of problem with the scroll not reaching the end of my defined scroll width. heres my repost of what i wrote in comments of robs original tutorial. the initial setting of the scroll view width doesn’t work, then if you set the external scrollwidth, the scrolling works but the actual scroll distance seems wrong?
Im running build 2511 on mac. graphics 2.0
Do we need to submit a bug report to get this fixed?
Hi Rob,
Firstly, Thanks for the tutorial. Great to get me started.
I have been playing around with the code for a little bit to look at using a scroll view for a menu system. However in my trials i cannot get the scroll to work the full width of the scrollWidth. For whatever reason the ‘menu’ only gets to about 2.70 x display.contentWidth. Not the full 3 x display.contentWidth.
Is there a maximum width or something else that might be causing this? Am i missing something, or is it a bug. Im running build 2511 on mac. graphics 2.0
cheers
Nick
[lua]
local widget = require( “widget” )
local scrollView
local icons = {}
local numMenuScreens = 3
local circleRadius = 200
local cW = display.contentWidth
local cH = display.contentHeight
local function iconListener( event )
local id = event.target.id
local object = event.target
if ( event.phase == “moved” ) then
local dx = math.abs( event.x - event.xStart )
if ( dx > 5 ) then
scrollView:takeFocus( event )
end
elseif ( event.phase == “ended” ) then
--take action if an object was touched
end
return true
end
local function myShowSlidingMenu( )
– if ( “ended” == event.phase ) then
scrollView = widget.newScrollView
{
width = cW,
height = cH,
scrollWidth = cW * numMenuScreens,
scrollHeight = 100,
verticalScrollDisabled = true, – horizontal scrolling only
isBounceEnabled = false
}
scrollView.x = display.contentCenterX
scrollView.y = display.contentCenterY
--generate icons
for i = 1, numMenuScreens do
icons[i] = display.newCircle( (i - 0.5 ) * cW, display.contentCenterY, circleRadius )
print( “Debug comment: icons[i].x” , icons[i].x )
icons[i]:setFillColor( math.random(), math.random(), math.random() )
scrollView:insert( icons[i] )
icons[i].id = i
icons[i]:addEventListener( “touch”, iconListener )
end
– end
return true
end
myShowSlidingMenu()
print( “Debug comment: my contentWidth” , cW ,“x3” , cW*3)
print("Debug comment: actual content width: ", scrollView._view.contentWidth)
– REMOVE THIS AND THE SCROLL DOESNT GO ALL THE WAY TO END
scrollView:setScrollWidth(cW * numMenuScreens)
print("Debug comment: actual content width after setScrollWidth(): ", scrollView._view.contentWidth)
[/lua]