How to make object scroll along the bottom of screen in scroll widget?

I’ve tried everything I put in the print statements but can’t get it to work and I’m all out of ideas :frowning:

[lua]

local widget = require “widget”

local scroller

local object

local function scrollListener (event)

if event.phase == “moved” then

print (“moving”)

object.y = display.contentHeight

print (display.contentHeight)                         -------------> 1334

print (display.viewableContentHeight)          -------------> 1334

print (display.pixelHeight)                             -------------> 1334

print (display.actualContentHeight)              -------------> 1334

print (object.y)                                               -------------> 1334

print (object.y + display.contentHeight)        -------------> 2668

print (scroller.scrollHeight)                           -------------> nil

end

end

scroller = widget.newScrollView{

scrollWidth = display.contentWidth,

scrollHeight = display.contentHeight*2,

hideBackground = true,

listener = scrollListener

}

object = display.newImage (“image.png”)

object:setReferencePoint (display.TopLeftReferencePoint)

object.xScale = 1.7

object.yScale = 1.7

object.x = display.contentWidth/35

scroller:insert (object)

[/lua]

Can you describe what you are trying to do with more detail? 

Hi Rob!

More or less, when user is scrolling up or down, I want my image of a hand (that’s pointing upwards) to stay at the bottom of the screen. So if the user scrolls the screen down, the hand will scroll down the same amount and remain at the bottom of the screen. And if the user scrolls up, the hand should also scroll up and stay at the bottom of the screen. 

What happens when I try it is that during an initial scroll the hand orients itself to the bottom of the screen. But if you try to scroll down some more, the hand stays in the same location and travels up the screen (as you’re scrolling down).

Hope that helped!

Don’t put the hand in the scrollView…  That would seem to accomplish your goal…

Rob

Hmm I guess I was just suffering from tunnel vision and didn’t take a step back!

Also here’s another question: where can I put my return true statement to prevent users from “touching” an item hidden behind the scroll view display? Can I put it in the widget.newScrollView (line 26) or do I have to put it under the scrollListener (line 5) – assuming that I don’t need the listener for anything else anymore and was planning on deleting it. 

Thanks for the help!

In the code above you don’t have any touch handlers to pass events from.  TableView touch events are handled by the widget and it takes care of the “return true” for you.  You could put one at line 23 above if you wish.

Rob

Can you describe what you are trying to do with more detail? 

Hi Rob!

More or less, when user is scrolling up or down, I want my image of a hand (that’s pointing upwards) to stay at the bottom of the screen. So if the user scrolls the screen down, the hand will scroll down the same amount and remain at the bottom of the screen. And if the user scrolls up, the hand should also scroll up and stay at the bottom of the screen. 

What happens when I try it is that during an initial scroll the hand orients itself to the bottom of the screen. But if you try to scroll down some more, the hand stays in the same location and travels up the screen (as you’re scrolling down).

Hope that helped!

Don’t put the hand in the scrollView…  That would seem to accomplish your goal…

Rob

Hmm I guess I was just suffering from tunnel vision and didn’t take a step back!

Also here’s another question: where can I put my return true statement to prevent users from “touching” an item hidden behind the scroll view display? Can I put it in the widget.newScrollView (line 26) or do I have to put it under the scrollListener (line 5) – assuming that I don’t need the listener for anything else anymore and was planning on deleting it. 

Thanks for the help!

In the code above you don’t have any touch handlers to pass events from.  TableView touch events are handled by the widget and it takes care of the “return true” for you.  You could put one at line 23 above if you wish.

Rob