Environment:
- newest Public Build: Version 2015.2646 (2015.5.27)
- newest Daily Build 2015.2693
My Code:
local widget = require( “widget” )
local scrollView
– ScrollView 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” )
local x, y = event.target:getContentPosition()
print ("X : " … x … " " … " Y : " … y)
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 top limit” )
elseif ( event.direction == “down” ) then print( “Reached bottom limit” )
elseif ( event.direction == “left” ) then print( “Reached left limit” )
elseif ( event.direction == “right” ) then print( “Reached right limit” )
end
end
return true
end
– Create the widget
scrollView = widget.newScrollView
{
top = 100,
left = 10,
width = 300,
height = 400,
scrollWidth = 800,
scrollHeight = 800,
listener = scrollListener
}
local myRectangle = display.newRect( 200, 200, 150, 50 )
myRectangle:setFillColor( 0.5 )
scrollView:insert(myRectangle)
The Issue:
_ When I remove this code: _
local myRectangle = display.newRect( 200, 200, 150, 50 )
myRectangle:setFillColor( 0.5 )
scrollView:insert(myRectangle)
I get an X and Y from this line (although it is still weird; i.e. Y/X never go Negative):
local x, y = event.target:getContentPosition()
print ("X : " … x … " " … " Y : " … y)
_ When I keep this code: _
local myRectangle = display.newRect( 200, 200, 150, 50 )
myRectangle:setFillColor( 0.5 )
scrollView:insert(myRectangle)
_ I get the same Y value, but X prints out to 0 no matter what I do. _
local x, y = event.target:getContentPosition()
print ("X : " … x … " " … " Y : " … y)
This code is part of a larger project and larger code base. We pushed an app almost a year ago that is time sensitive and needs to be update. As of right now I was seeing the bug in my previous code and could not figure it out so I decided to make a more simple app to test (this code). I am seeing the same issue. Basically I see no reason why the X of this: local x, y = event.target:getContentPosition() should ever be 0.
This is pretty critical and I could use some advice ASAP or figure out that it is a known bug.
Thanks,