ScrollView event.limitReached not working

I was implementing a scrollView and I noticed as I was using the default code that if I added the default listener 

local function scrollListener( event ) local phase = event.phase if ( phase == "began" ) then print( "Scroll view was touched" ) elseif ( phase == "moved" ) then print( "Scroll view was moved" ) elseif ( phase == "ended" ) then print( "Scroll view was released" ) end -- In the event a scroll limit is reached... if ( event.limitReached ) then if ( event.direction == "up" ) then print( "Reached bottom limit" ) elseif ( event.direction == "down" ) then print( "Reached top limit" ) elseif ( event.direction == "left" ) then print( "Reached right limit" ) elseif ( event.direction == "right" ) then print( "Reached left limit" ) end end return true end

The part where event.limitReached doesn’t work at all. 

On a second note, does anyone have any idea to create an infinite scrolling scrollview. So that If had multiple pages, lets say hundreds I could have them accessible within a scrollview. 

What does your ScrollView widget constructor look like?

local scrollView = widget.newScrollView { verticalScrollDisabled = true, isBounceEnabled = false, hideBackground = true, rightPadding = 16, }

Hi @lofy,

Did you forget to actually specify the “listener” parameter in the constructor?

I get the proper behavior using this exact code:

[lua]

local widget = require “widget”

local function scrollListener( event )

    local phase = event.phase

    – In the event a scroll limit is reached…

    if ( event.limitReached ) then

        if ( event.direction == “up” ) then print( “Reached bottom limit” )

        elseif ( event.direction == “down” ) then print( “Reached top limit” )

        elseif ( event.direction == “left” ) then print( “Reached right limit” )

        elseif ( event.direction == “right” ) then print( “Reached left limit” )

        end

    end

    return true

end

local scrollView = widget.newScrollView

    {

        verticalScrollDisabled = true,

        isBounceEnabled = false,

        hideBackground = false,

        rightPadding = 16,

        x = display.contentCenterX,

        y = display.contentCenterY,

        listener = scrollListener  – <— CLEARLY THIS IS NEEDED

    }

local r = display.newRect( 100,0,180,50 )

r:setFillColor(1,0,0)

scrollView:insert®

[/lua]

Take care,

Brent

Even with this code I don’t get any of those messages printing.

What build of Corona are you using? I tried this exact code in 2017.3068 (latest public release) and I saw the prints consistently.

I assume you’re not “over-riding” the widget library with some custom version of it or something like that?

Brent

What does your ScrollView widget constructor look like?

local scrollView = widget.newScrollView { verticalScrollDisabled = true, isBounceEnabled = false, hideBackground = true, rightPadding = 16, }

Hi @lofy,

Did you forget to actually specify the “listener” parameter in the constructor?

I get the proper behavior using this exact code:

[lua]

local widget = require “widget”

local function scrollListener( event )

    local phase = event.phase

    – In the event a scroll limit is reached…

    if ( event.limitReached ) then

        if ( event.direction == “up” ) then print( “Reached bottom limit” )

        elseif ( event.direction == “down” ) then print( “Reached top limit” )

        elseif ( event.direction == “left” ) then print( “Reached right limit” )

        elseif ( event.direction == “right” ) then print( “Reached left limit” )

        end

    end

    return true

end

local scrollView = widget.newScrollView

    {

        verticalScrollDisabled = true,

        isBounceEnabled = false,

        hideBackground = false,

        rightPadding = 16,

        x = display.contentCenterX,

        y = display.contentCenterY,

        listener = scrollListener  – <— CLEARLY THIS IS NEEDED

    }

local r = display.newRect( 100,0,180,50 )

r:setFillColor(1,0,0)

scrollView:insert®

[/lua]

Take care,

Brent

Even with this code I don’t get any of those messages printing.

What build of Corona are you using? I tried this exact code in 2017.3068 (latest public release) and I saw the prints consistently.

I assume you’re not “over-riding” the widget library with some custom version of it or something like that?

Brent