Error when using scrollview inside other scrollview in build 2014.2393

The error “Attempt to call method ‘_loseFocus’ (a nil value)” occures in this kind of case:

local svScreen = widget.newScrollView{

  width = display.contentWidth , 

  height = display.contentHeight,

}

local svPhotos = widget.newScrollView{ 

  width = display.contentWidth , 

  height = display.contentHeight,

  listener = function(event)

    local phase = event.phase

    if ( phase == “moved” ) then

        local dy = math.abs( ( event.y - event.yStart ) )

        if ( dy > 10 ) then

          svScreen:takeFocus(event)

        end

    end

  end,

}

In version 2014.2189 the same error does not occur.

Hi @RexeL86,

Can you place “return true” at the end of your listener function and see if the issue persists?

Thanks,

Brent

Thanks for answering.

The error still occurs.

Hi @RexeL86,

Next, please pull the listener function outside and above of the widget constructor block, and point to it from within the constructor.

Thanks,

Brent

Hi Brent,

Since I have the same problem (it looks really similar to the casenum 31363 -supposedly resolved in v2393-), I guess I can answer. In my case I’m using the latest build, v2407, and as said in the first post our code works perfectly fine with v2189.

I made this little test case, with an horizontal blue scroll and a vertical red one. In this project each scroll is supposed to give focus to the another if the dy/dx ratio says so… but it never works, always throwing “?:0: attempt to call method ‘_loseFocus’ (a nil value)”

https://www.dropbox.com/s/5jz0rjkn966esrl/Double%20scroll.zip

Hi @Mangoo, @RexeL86,

I glanced at your project and I don’t understand what you’re trying to do. Can you explain the UI design here? If you’re trying to use one scrollView inside another, what is this shifting of focus for? When the user manipulates the “child” (SV2), it should retain control. When the user manipulates the “parent” (SV1), it should retain control while the child (SV2) scrolls along in sync. When would focus be shifted, and why? I think I’ll need a very detailed explanation of the design theory here, and maybe some screenshots on what is supposed to happen.

Thanks,

Brent

You may need to use an horizontal scrollview inside a vertical one. For example, you may want to present a list of items and textual information of them vertically and several images of those items horizontally. It is more user-friendly that you can scroll the list vertically by touching both of those lists than only touching the vertical list. Example image: https://www.dropbox.com/s/wz2hiw5dql3cunq/example.png

It’s as @RexeL86 said : in our project we have a gallery of pictures at the bottom of one of our pages, and this page is long so we need a vertical scrollview.

The goal is that the background and the top of the long page don’t have to move if you scroll (horizontally) the pictures’ gallery, but all the page (the background, the top of the page and the “current image”) have to scroll vertically if the user wants to.

Edit : as you probably understood, in our app one of the scrollview is inserted into the other one, which is not the case in my little test (I forgot that when I did it) but since the bug remains the same I don’t think it really matters.

Thanks, I understand your usage cases now. I’ll look into this (hopefully) today and see what might be causing the issue.

Brent

Hi guys,

I was able to reproduce this issue, and I’ve submitted it as a bug report to the engineers so they can investigate. Case number is #35215.

Thanks,

Brent

Hi, 

I have the same issue now.
I still have one scrollView with some Buttons in it.

The scrollView worked fine.

The lua file with the scrollView in it was finished and I worked on an other file.

And then the issue appears… 

I tried to fix it but don’t know how.

It seems on the device the issue does not appear.

But it still sucks.

Hi @RexeL86,

Can you place “return true” at the end of your listener function and see if the issue persists?

Thanks,

Brent

Thanks for answering.

The error still occurs.

Hi @RexeL86,

Next, please pull the listener function outside and above of the widget constructor block, and point to it from within the constructor.

Thanks,

Brent

Hi Brent,

Since I have the same problem (it looks really similar to the casenum 31363 -supposedly resolved in v2393-), I guess I can answer. In my case I’m using the latest build, v2407, and as said in the first post our code works perfectly fine with v2189.

I made this little test case, with an horizontal blue scroll and a vertical red one. In this project each scroll is supposed to give focus to the another if the dy/dx ratio says so… but it never works, always throwing “?:0: attempt to call method ‘_loseFocus’ (a nil value)”

https://www.dropbox.com/s/5jz0rjkn966esrl/Double%20scroll.zip

Hi @Mangoo, @RexeL86,

I glanced at your project and I don’t understand what you’re trying to do. Can you explain the UI design here? If you’re trying to use one scrollView inside another, what is this shifting of focus for? When the user manipulates the “child” (SV2), it should retain control. When the user manipulates the “parent” (SV1), it should retain control while the child (SV2) scrolls along in sync. When would focus be shifted, and why? I think I’ll need a very detailed explanation of the design theory here, and maybe some screenshots on what is supposed to happen.

Thanks,

Brent

You may need to use an horizontal scrollview inside a vertical one. For example, you may want to present a list of items and textual information of them vertically and several images of those items horizontally. It is more user-friendly that you can scroll the list vertically by touching both of those lists than only touching the vertical list. Example image: https://www.dropbox.com/s/wz2hiw5dql3cunq/example.png

It’s as @RexeL86 said : in our project we have a gallery of pictures at the bottom of one of our pages, and this page is long so we need a vertical scrollview.

The goal is that the background and the top of the long page don’t have to move if you scroll (horizontally) the pictures’ gallery, but all the page (the background, the top of the page and the “current image”) have to scroll vertically if the user wants to.

Edit : as you probably understood, in our app one of the scrollview is inserted into the other one, which is not the case in my little test (I forgot that when I did it) but since the bug remains the same I don’t think it really matters.

Thanks, I understand your usage cases now. I’ll look into this (hopefully) today and see what might be causing the issue.

Brent

Hi guys,

I was able to reproduce this issue, and I’ve submitted it as a bug report to the engineers so they can investigate. Case number is #35215.

Thanks,

Brent