Scrollview won't scroll?

Hi - I have added a scrollview to my scene group (I’m using storyboard api) and added some rects to the scrollview (for testing purposes). But the scrollview won’t scroll.

Note that the code below is the entire scene. I haven’t done anything else yet - I just want to make the scrollview scroll :slight_smile:

I would be incredibly grateful if anyone could point out why the scrollview isn’t scrolling.

Thanks in advance!

The code I am using looks like this:

local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local level\_data = require( "settings\_levels" ) local widget = require( "widget" ) -- local function onButtonReturn( event ) storyboard.gotoScene( storyboard.getPrevious(), 'slideDown', 500 ) return true end -- local function scrollListener( event ) local phase = event.phase local direction = event.direction if "began" == phase then --print( "Began" ) elseif "moved" == phase then --print( "Moved" ) elseif "ended" == phase then --print( "Ended" ) end end -- Called when the scene's view does not exist: function scene:createScene( event ) local group = self.view self.menu = {} -- background image background = display.newImageRect( "scenes/intro/background.png", display.contentWidth, display.contentHeight ) background.x = display.contentWidth / 2 background.y = display.contentHeight / 2 group:insert( background ) -- Create a ScrollView local scrollView = widget.newScrollView { left = 10, top = 10, width = display.contentWidth - 20, height = display.contentHeight - 90, verticalScrollDisabled = true, listener = scrollListener, hideScrollBar = true, isLocked = false, --hideBackground = true, } group:insert( scrollView ) --scrollView:takeFocus() local x = 0 for i = 10, 1, -1 do local rect = display.newRect( scrollView, x, 10, 110, 200 ) rect:setFillColor( 0, 0, 0 ) rect.alpha = 0.5 x = x + 130 end local menuButton menuButton = widget.newButton( { defaultFile = "scenes/menu/button.png", label = "Close", width = 120, height = 60, font = gameConst.font, labelColor = gameConst.labelStyle, onRelease = onButtonReturn, left = screenCenterX - 60, top = display.contentHeight - 70, id = "playButton", } ) group:insert( menuButton ) end -- Called BEFORE scene has moved onscreen: function scene:enterBegan( event ) local group = self.view end -- Called immediately after scene has moved onscreen: function scene:enterScene( event ) local group = self.view end -- Called when scene is about to move offscreen: function scene:exitScene( event ) local group = self.view end -- Called AFTER scene has finished moving offscreen: function scene:exitEnded( event ) local group = self.view end -- Called prior to the removal of scene's "view" (display group) function scene:destroyScene( event ) local group = self.view end -- "createScene" event is dispatched if scene's view does not exist scene:addEventListener( "createScene", scene ) -- "enterBegan" event is dispatched before scene transition begins scene:addEventListener( "enterBegan", scene ) -- "enterScene" event is dispatched whenever scene transition has finished scene:addEventListener( "enterScene", scene ) -- "exitScene" event is dispatched before next scene's transition begins scene:addEventListener( "exitScene", scene ) -- "exitEnded" event is dispatched after scene has finished transitioning out scene:addEventListener( "exitEnded", scene ) -- "destroyScene" event is dispatched before view is unloaded, which can be -- automatically unloaded in low memory situations, or explicitly via a call to -- storyboard.purgeScene() or storyboard.removeScene(). scene:addEventListener( "destroyScene", scene ) return scene

Ah ha - it seems that doing this doesn’t work

local rect = display.newRect( scrollView, x, 10, 110, 200 ) 

and this does

local rect = display.newRect( x, 10, 110, 200 ) scrollView:insert( rect )

Bit weird - and probably a bug (unless there’s a reason for it?)

But since it works I don’t care - I’m happy :slight_smile:

Ah ha - it seems that doing this doesn’t work

local rect = display.newRect( scrollView, x, 10, 110, 200 ) 

and this does

local rect = display.newRect( x, 10, 110, 200 ) scrollView:insert( rect )

Bit weird - and probably a bug (unless there’s a reason for it?)

But since it works I don’t care - I’m happy :slight_smile:

Thanks! just came across the same issue and this resolved the problem.

Little annoying bug and since you’ve posted this nobody bothered to fix it yet.

Actually I saw the email thread with engineering.  This actually is by design.  The scrollview object is not a display group.  It has a member that is the actual display group, so by passing in the scrollview object, you are passing in something display.* doesn’t know about.

Rob

Hi Rob, thanks for your input.

As documented here:

http://docs.coronalabs.com/api/library/widget/newScrollView.html

It says “Because the scroll view is technically a display group, visual content can be added to or removed from a scroll view in the same manner as a standard display group.”

Perhaps adding a note in regards to this difference might save others some time :slight_smile:

Cheers

I’ll get the documentation updated.

Thanks! just came across the same issue and this resolved the problem.

Little annoying bug and since you’ve posted this nobody bothered to fix it yet.

Actually I saw the email thread with engineering.  This actually is by design.  The scrollview object is not a display group.  It has a member that is the actual display group, so by passing in the scrollview object, you are passing in something display.* doesn’t know about.

Rob

Hi Rob, thanks for your input.

As documented here:

http://docs.coronalabs.com/api/library/widget/newScrollView.html

It says “Because the scroll view is technically a display group, visual content can be added to or removed from a scroll view in the same manner as a standard display group.”

Perhaps adding a note in regards to this difference might save others some time :slight_smile:

Cheers

I’ll get the documentation updated.