Help! Native Scroller..
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Help! Native Scroller..
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
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
- Attachments
-
- 2013.12.03 Native Scroller.zip
- (1.54 KiB) Downloaded 149 times
Re: Help! Native Scroller..
Hi Matthew,
this works, see my comments:
Best
Klaus
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
Klaus
Re: Help! Native Scroller..
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
--
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
--
- Attachments
-
- Native Scroller.livecode.zip
- (2.06 KiB) Downloaded 148 times
Re: Help! Native Scroller..
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
Thanks
Matthew
Re: Help! Native Scroller..
Why shouldn't the buttons not be clickable?
There is no reason for this.
There is no reason for this.
Re: Help! Native Scroller..
Yes, I have just checked it and they are, I assumed they weren't due to the comments below the lesson.
Thanks
Matthew
Thanks
Matthew