Widget 2.0 Getcontentposition In Scrollviewlistener Throws A Error (Using Build 2013.1073)

When i try to do getContentPosition  in the scrollViewListener function i get a error "Attempt to call method getContentPosition (a nil value),

Thanks

When i try to do getContentPosition  in the scrollViewListener function i get a error "Attempt to call method getContentPosition (a nil value),

Thanks

Can you post up some code please?

– function to listen to scrollView events
scrollViewListener = function( event )
    local s = event.target    – reference to scrollView object

    local x,y = s:getContentPosition()    – This is the line where it throws the error.

    if event.type == “beganScroll” then
    –   print( “beganScroll event type” )

    elseif event.type == “movingToTopLimit” or event.type == “endedScroll”  then
        if y > 0 then
            s:scrollToPosition(nil, 0, 400 )
        end
    elseif event.type == “movingToBottomLimit” then
    –    print( “movingToBottomLimit event type” )

    elseif event.type == “movingToLeftLimit” then
    –    print( “movingToLeftLimit event type” )

    elseif event.type == “movingToRightLimit” then
     –   print( “movingToRightLimit event type” )
    end
end

I’m having issues with 2013.1073 daily build too… on scenes in my app that use   widget.newScrollView

All I’m getting in the annoying new error popup window is :

File: ?

Attempt to compare number with nil

stack traceback:

    [C]: ?

    ?: in function ‘_listener’

    ?: in function <?:141>

    ?: in function <?:218>

Is there a bug with this build?

Looks like event.target is scrollView._view rather than scrollView

So for the time being this will resolve your issue (until we get to fix it)

local x,y = s.parent:getContentPosition()    – This is the line where it throws the error.

Hi Danny. I’ve been stuck on my scrollview scene for a few days now. Please could you help clear up a few things…

1. Does the following still work to remove a scrollview or is there still a bug with the _view group? I just can’t seem to remove it which I need to do for rebuilding the scene on orientation change.

scrollView:removeSelf() scrollView = nil&nbsp;

2.  I have a couple of buttons outside of my scrollView widget object that call the scrollView:scrollToPosition() method so the user can scroll the content up and down with button touches. This is working appart from it isn’t being limited in the same way that dragging is. When it reaches the top or bottom the scrollView:scrollToPosition() method continues to scroll the content. I was wondering if there was something like event.limitReached for the scrollToPosition onComplete so I can rectify this?

3.  Can you also let me know if the scrollView:takeFocus() method is coming back? I noticed it’s not in the daily build documentation.

Cheers.

if I call :

scrollView:removeSelf() scrollView = nil 

I get the following error:

Corona Simulator Runtime error

File: ?

Attempt to compare number with nil

stack traceback:

?: in function ‘_listener’

?: in function <?:141>

?: in function <?:218>

However I know I’m targeting the right object because I am able to do the following and it is hidden:

scrollView.isVisible = false

Any ideas?

Hey Julius.

Would you be so kind as to make up a simple test case which exhibits this issue and then [buglink].

That way I can investigate this issue and keep track of it

It throws the same error if you use build 2013.1076 (Starter Pack Version) . Please fix

When i try to do getContentPosition  in the scrollViewListener function i get a error "Attempt to call method getContentPosition (a nil value),

Thanks

Can you post up some code please?

– function to listen to scrollView events
scrollViewListener = function( event )
    local s = event.target    – reference to scrollView object

    local x,y = s:getContentPosition()    – This is the line where it throws the error.

    if event.type == “beganScroll” then
    –   print( “beganScroll event type” )

    elseif event.type == “movingToTopLimit” or event.type == “endedScroll”  then
        if y > 0 then
            s:scrollToPosition(nil, 0, 400 )
        end
    elseif event.type == “movingToBottomLimit” then
    –    print( “movingToBottomLimit event type” )

    elseif event.type == “movingToLeftLimit” then
    –    print( “movingToLeftLimit event type” )

    elseif event.type == “movingToRightLimit” then
     –   print( “movingToRightLimit event type” )
    end
end

I’m having issues with 2013.1073 daily build too… on scenes in my app that use   widget.newScrollView

All I’m getting in the annoying new error popup window is :

File: ?

Attempt to compare number with nil

stack traceback:

    [C]: ?

    ?: in function ‘_listener’

    ?: in function <?:141>

    ?: in function <?:218>

Is there a bug with this build?

Looks like event.target is scrollView._view rather than scrollView

So for the time being this will resolve your issue (until we get to fix it)

local x,y = s.parent:getContentPosition()    – This is the line where it throws the error.

Hi Danny. I’ve been stuck on my scrollview scene for a few days now. Please could you help clear up a few things…

1. Does the following still work to remove a scrollview or is there still a bug with the _view group? I just can’t seem to remove it which I need to do for rebuilding the scene on orientation change.

scrollView:removeSelf() scrollView = nil&nbsp;

2.  I have a couple of buttons outside of my scrollView widget object that call the scrollView:scrollToPosition() method so the user can scroll the content up and down with button touches. This is working appart from it isn’t being limited in the same way that dragging is. When it reaches the top or bottom the scrollView:scrollToPosition() method continues to scroll the content. I was wondering if there was something like event.limitReached for the scrollToPosition onComplete so I can rectify this?

3.  Can you also let me know if the scrollView:takeFocus() method is coming back? I noticed it’s not in the daily build documentation.

Cheers.

if I call :

scrollView:removeSelf() scrollView = nil 

I get the following error:

Corona Simulator Runtime error

File: ?

Attempt to compare number with nil

stack traceback:

?: in function ‘_listener’

?: in function <?:141>

?: in function <?:218>

However I know I’m targeting the right object because I am able to do the following and it is hidden:

scrollView.isVisible = false

Any ideas?

Hey Julius.

Would you be so kind as to make up a simple test case which exhibits this issue and then [buglink].

That way I can investigate this issue and keep track of it

It throws the same error if you use build 2013.1076 (Starter Pack Version) . Please fix

Hi Danny.
I’m really struggling with scrollview and have spent far too long going over it. I do believe it to be a bug so please let me know how I can file it (I’ve never done it before)

Description of use:
Essentially I have a big generic function in my app that accepts various parameters to create scrolling content objects on a few scenes with various stuff in them.
The function creates and returns a display group object with a scrollView inside it; to which is attached an internal resize function to handle orientation change. In this resize function I’m trying to remove and rebuild the scrollview to the new screen dimensions after orientation change. But whenever I try to remove the scrollView I get the error. Below is an example of how to recreate the error. (commenting out the last line stops the error)

 

local widget = require "widget" local left = display.screenOriginX local top = display.screenOriginY local width = display.viewableContentWidth - (display.screenOriginX\*2) local height = display.viewableContentHeight - (display.screenOriginY\*2) - 100 local scrollMask = display.newRect(left,top,width,height) display.save (scrollMask, "scroll\_content\_mask"..width.."x"..height..".jpg", system.TemporaryDirectory) scrollMask:removeSelf(); scrollMask = nil local scroller = widget.newScrollView{ width = width, height = height, scrollWidth = width, scrollHeight = height, left = left, top = top, baseDir = system.TemporaryDirectory, maskFile = "scroll\_content\_mask"..width.."x"..height..".jpg", hideBackground = true, } for i=1, 20 do local rect = display.newRect(0, 0, width-100, 50) rect:setReferencePoint(display.TopLeftReferencePoint) rect:setFillColor( 200, 100, 50 ) rect.x = left + 50 rect.y = top + i\*70 scroller:insert( rect ) end scroller:removeSelf()

Error message:

Attempt to compare number with nil

stack traceback:
[C]: ?

?: in function ‘_listener’

?: in function <?:141>

?: in function <?:218>

Hi Danny.
I’m really struggling with scrollview and have spent far too long going over it. I do believe it to be a bug so please let me know how I can file it (I’ve never done it before)

Description of use:
Essentially I have a big generic function in my app that accepts various parameters to create scrolling content objects on a few scenes with various stuff in them.
The function creates and returns a display group object with a scrollView inside it; to which is attached an internal resize function to handle orientation change. In this resize function I’m trying to remove and rebuild the scrollview to the new screen dimensions after orientation change. But whenever I try to remove the scrollView I get the error. Below is an example of how to recreate the error. (commenting out the last line stops the error)

 

local widget = require "widget" local left = display.screenOriginX local top = display.screenOriginY local width = display.viewableContentWidth - (display.screenOriginX\*2) local height = display.viewableContentHeight - (display.screenOriginY\*2) - 100 local scrollMask = display.newRect(left,top,width,height) display.save (scrollMask, "scroll\_content\_mask"..width.."x"..height..".jpg", system.TemporaryDirectory) scrollMask:removeSelf(); scrollMask = nil local scroller = widget.newScrollView{ width = width, height = height, scrollWidth = width, scrollHeight = height, left = left, top = top, baseDir = system.TemporaryDirectory, maskFile = "scroll\_content\_mask"..width.."x"..height..".jpg", hideBackground = true, } for i=1, 20 do local rect = display.newRect(0, 0, width-100, 50) rect:setReferencePoint(display.TopLeftReferencePoint) rect:setFillColor( 200, 100, 50 ) rect.x = left + 50 rect.y = top + i\*70 scroller:insert( rect ) end scroller:removeSelf()

Error message:

Attempt to compare number with nil

stack traceback:
[C]: ?

?: in function ‘_listener’

?: in function <?:141>

?: in function <?:218>

Hi Julius,

Have something quite similar - did you ever get the error resolved?

Peter