Page 1 of 1
Help! Native Scroller..
Posted: Wed Dec 04, 2013 5:32 pm
by mattrgs
Hi
I have been trying to implement a scroller for a group of buttons, and was trying the native scroller, following the lesson, but I can't get it to work.

I've attached my test app, so you can please check if it is an error in my coding.
Thanks
Matthew
Re: Help! Native Scroller..
Posted: Wed Dec 04, 2013 5:46 pm
by Klaus
Hi Matthew,
this works, see my comments:
Code: Select all
on preOpenCard
if environment() is not "mobile" then
exit preOpenCard
end if
put the rect of group "group" into tScrollerRect
##put the left of group "group",the top of button "button1",the right of
## TYPO: ...the right of FIELD "group"!!!???
## But the content rect is the "scrollable area" and not the current rect of that group:
put 0 & "," & 0 & "," & the width of grp "group" & "," & the formattedheight of group "group" into tContentRect
mobileControlCreate "scroller", "GroupScroll"
put the result into sScrollerID
mobileControlSet "GroupScroll", "rect", tScrollerRect
mobileControlSet "GroupScroll", "contentRect", tContentRect
mobileControlSet "GroupScroll", "visible", true
mobileControlSet "GroupScroll", "scrollingEnabled", true
mobileControlSet "GroupScroll", "vIndicator", true
mobileControlSet "GroupScroll", "vscroll", 0
end preOpenCard
on scrollerDidScroll hOffset, vOffset
// When the user scrolls move the displayed content
set the vScroll of group "group" to vOffset
end scrollerDidScroll
Best
Klaus
Re: Help! Native Scroller..
Posted: Wed Dec 04, 2013 5:47 pm
by LCNeil
Hi Matthew,
I have amended your stack by creating an additional group o your buttons. I slightly changed your script to put the correct contents into tContentRect. The scroller should now work as expected.
I hope this gives you some leads.
Kind Regards
Neil Roger
--
RunRev Support Team ~
http://www.runrev.com
LiveCode – Realize fast, compile-free coding
--
Re: Help! Native Scroller..
Posted: Wed Dec 04, 2013 10:22 pm
by mattrgs
Thanks to both of your replies. I think I will probably use Klaus' solution as it requires less groups, which means that it is slightly simpler. To allow the buttons to be clickable, I assume that I would have to put in a line that checked whether it had been moved a certain distance, but how would I then allow the buttons functions to happen, as each button has a different thing which it does.
Thanks
Matthew
Re: Help! Native Scroller..
Posted: Wed Dec 04, 2013 10:31 pm
by Klaus
Why shouldn't the buttons not be clickable?
There is no reason for this.
Re: Help! Native Scroller..
Posted: Wed Dec 04, 2013 10:34 pm
by mattrgs
Yes, I have just checked it and they are, I assumed they weren't due to the comments below the lesson.
Thanks
Matthew