event.phase not detected in scrollListener of scrollview

Hey, 

I am currently using the CoronaSKD-2013.2076 - latest version of the CoronaSDK that includes Graphics 2.0 and have encountered a (for this project) big issue. The phases are not sent along.

Using following code I look at all the values in the event table

local scrollListener = function(event) for key,value in pairs(event) do print(key,value) end end slider = widget.newScrollView { top = 275, left = 0, width = display.contentWidth, height = 350, scrollWidth = 465, scrollHeight = 670, friction = 0, verticalScrollDisabled = true, listener = scrollListener, hideScrollBar = true, backgroundColor = {0,0,0,0} }

Only this is returned:

 target table: 0x7fb8de4202e0 direction right limitReached false 

No phase is being sent with the event table. How can I fix this?

You can’t. It’s a bug in Corona SDK. You’re at least the fourth person to notice it, and there’s a discussion here as well:

http://forums.coronalabs.com/topic/41489-scrollview-eventphase-returns-nil/

I filed it as a bug yesterday afternoon (Case 28117) but have not received a response from Corona yet.

FYI, there’s Yet Another Thread (this one is in the daily builds section) noting this bug as well:

http://forums.coronalabs.com/topic/41361-daily-build-1260-broke-scrollview-listeners/

Hi @corona273,

This fix will be rolled into a G2.0 daily soon. Thanks for bumping it.

Brent

For anyone who doesn’t have a subscription to get the daily build with the fix, I hacked out a quick fix in the meantime:

 

local isBegan = true local scrollTimer      -- ScrollView listener local function scrollListener( event )             if(scrollTimer~=nil)then         timer.cancel(scrollTimer)     end              if(isBegan==true)then         print("Phase Began")         isBegan = false else print("Phase Moved")     end              local function phaseEnded()         print("Phase Ended")         isBegan = true     end scrollTimer=timer.performWithDelay(150,phaseEnded,1) end  

If it’s a slow swipe, the began phase might be called multiple times…if this is happening, increase the timer from 150 to 200 or 300. Tweak around a bit, and you should get it good enough for the moment!

You can’t. It’s a bug in Corona SDK. You’re at least the fourth person to notice it, and there’s a discussion here as well:

http://forums.coronalabs.com/topic/41489-scrollview-eventphase-returns-nil/

I filed it as a bug yesterday afternoon (Case 28117) but have not received a response from Corona yet.

FYI, there’s Yet Another Thread (this one is in the daily builds section) noting this bug as well:

http://forums.coronalabs.com/topic/41361-daily-build-1260-broke-scrollview-listeners/

Hi @corona273,

This fix will be rolled into a G2.0 daily soon. Thanks for bumping it.

Brent

For anyone who doesn’t have a subscription to get the daily build with the fix, I hacked out a quick fix in the meantime:

 

local isBegan = true local scrollTimer      -- ScrollView listener local function scrollListener( event )             if(scrollTimer~=nil)then         timer.cancel(scrollTimer)     end              if(isBegan==true)then         print("Phase Began")         isBegan = false else print("Phase Moved")     end              local function phaseEnded()         print("Phase Ended")         isBegan = true     end scrollTimer=timer.performWithDelay(150,phaseEnded,1) end  

If it’s a slow swipe, the began phase might be called multiple times…if this is happening, increase the timer from 150 to 200 or 300. Tweak around a bit, and you should get it good enough for the moment!

Version 2014.2122 (2014.1.4)

it seems the phase.direction works initially, but after I bring up a newscene with a tableview in it, going back to the scrollview scene the phase.direction = nil.

luckily event.y and event.yStart are reporting good numbers to figure out the scroll direction.

Version 2014.2122 (2014.1.4)

it seems the phase.direction works initially, but after I bring up a newscene with a tableview in it, going back to the scrollview scene the phase.direction = nil.

luckily event.y and event.yStart are reporting good numbers to figure out the scroll direction.