I have implemented the NewList widget with a parent list in one of my storyboard scenes. Unfortunately, when I touch the back button and return to the parent list, it goes to the top of the list, instead of the location where it was when the row was tapped. I have tried using the :scrollTo method within the onBackButton function but it doesn’t work. The Output-Simulator indicates SCROLL! (which I changed to SCROLL to numItems in the widget_candy.lua file.) My fix shows that it thinks it’s scrolling to the Xth ItemNumber but doesn’t actually go there.
I tried a whole bunch of scenarios using delays and/or transitions, and found a simple work-around. I added a call to a listener function using timer.performWithDelay within the onBackButton function which then called the :scrollTo method. Note: This function could not be defined within the scope of the onBackButton function. My guess is because the list is not actually rendered until this function completes execution.
Are there any plans to add a property which would automatically do this?
Here is the code I created:
local function scrollToLastLoc (event) local scrollToMember = \_G.App.Get("parentListDataIndex") print ("Scroll to member table location: "..tostring(scrollToMember)) \_G.GUI.GetHandle(\_G.Scenes.RSTR\_LIST\_NAME):scrollTo( scrollToMember ) end local function backToMemberList( EventData ) timer.performWithDelay( 500, scrollToLastLoc) end
Note: “parentListDataIndex” is saved in the onSelect function call.