Help! Native Scroller..

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
mattrgs
Posts: 37
Joined: Tue May 28, 2013 1:41 pm

Help! Native Scroller..

Post by mattrgs » Wed Dec 04, 2013 5:32 pm

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
Attachments
2013.12.03 Native Scroller.zip
(1.54 KiB) Downloaded 149 times

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Help! Native Scroller..

Post by Klaus » Wed Dec 04, 2013 5:46 pm

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

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Help! Native Scroller..

Post by LCNeil » Wed Dec 04, 2013 5:47 pm

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

--
Attachments
Native Scroller.livecode.zip
(2.06 KiB) Downloaded 148 times

mattrgs
Posts: 37
Joined: Tue May 28, 2013 1:41 pm

Re: Help! Native Scroller..

Post by mattrgs » Wed Dec 04, 2013 10:22 pm

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

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Help! Native Scroller..

Post by Klaus » Wed Dec 04, 2013 10:31 pm

Why shouldn't the buttons not be clickable? :shock:
There is no reason for this.

mattrgs
Posts: 37
Joined: Tue May 28, 2013 1:41 pm

Re: Help! Native Scroller..

Post by mattrgs » Wed Dec 04, 2013 10:34 pm

Yes, I have just checked it and they are, I assumed they weren't due to the comments below the lesson.
Thanks
Matthew

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”