CanBounce Scrolling with DataGrid
Posted: Mon May 14, 2012 7:14 pm
I am using the code below to get a datagrid to scroll. I have everything working how I want it except one small thing. For some reason, I can't get the "bounce" effect to work. The scroller works fine, and even the scrolling indicator on the right side makes it look like it knows to bounce, but the text in the datagrid doesn't. Any ideas on what could be going on here? Thanks
Code: Select all
-- Create the scroller and store its id
iphoneControlCreate "scroller"
put the result into sScrollerId
-- The 'rect' is the region of the card it should cover
iphoneControlSet sScrollerId, "rect", the rect of group 1
-- The 'contentRect' is the region the scroller scrolls over
-- To determine it for a data grid, calculate the size of the grid as if it was expanded fully to fit its contents
iphoneControlSet sScrollerId, "contentRect", (0, 0, (the dgFormattedWidth of grp 1),(the dgFormattedHeight of grp 1))
-- The 'visible' determines if the scroller is displayed
iphoneControlSet sScrollerId, "visible", "true"
-- The 'canBounce' determines whether the standard iOS 'bouncing' occurs
-- at extremities of scrolling
iphoneControlSet sScrollerId, "canBounce", "true"
-- The 'pagingEnabled' determines whether scrolling only happens in multiples
-- of the width/height
iphoneControlSet sScrollerId, "pagingEnabled", "false"
-- The 'canScrollToTop' determines whether touching the status bar scrolls
-- the scroller to the top
iphoneControlSet sScrollerId, "canScrollToTop", "false"
end InstantiateScroller
on scrollerDidScroll pOffsetX, pOffsetY
-- Set the scroll values of the group based on feedback from the scroller
-- notice that we can just use the values directly and because out-of-bounds
-- scrolling is enabled for the group, the bounce effect needs no extra
-- code.
lock screen
set the dghScroll of group 1 to pOffsetX
set the dgvScroll of group 1 to pOffsetY
unlock screen
end scrollerDidScroll