Copying groups into a 'master' group to create a mobile scro
Posted: Fri Dec 12, 2014 2:08 pm
Hi,
I'm trying (without much success) to dynamically create a series of graphical buttons which need to be added to a group which can then be scrolled using the mobileControlCreate command so I end up with a graphical menu for an iOS app I'm writing.
The problem is, looking at the API documentation, I don't seem to be able to copy a group to a group - is it possible to do this, or am I just looking at the problem in the wrong way?
Explanation
--------------
I have a group, stored on a separate card which comprises of a background image (an arrow) over that is placed an image, a title and subtitle, a cost and a 'play' button
I want to create a scroller on my device which will contain multiple copies of the group described above which will act as menu items, allowing the user to select an option and see relevant details on another card.
I used the code mentioned in one of the tutorials to (hopefully) create the native scroller but it doesn't seem to work (I think because I'm trying to copy a group into another group).
Thx
Crussell
The code I have so far is:
I'm trying (without much success) to dynamically create a series of graphical buttons which need to be added to a group which can then be scrolled using the mobileControlCreate command so I end up with a graphical menu for an iOS app I'm writing.
The problem is, looking at the API documentation, I don't seem to be able to copy a group to a group - is it possible to do this, or am I just looking at the problem in the wrong way?
Explanation
--------------
I have a group, stored on a separate card which comprises of a background image (an arrow) over that is placed an image, a title and subtitle, a cost and a 'play' button
I want to create a scroller on my device which will contain multiple copies of the group described above which will act as menu items, allowing the user to select an option and see relevant details on another card.
I used the code mentioned in one of the tutorials to (hopefully) create the native scroller but it doesn't seem to work (I think because I'm trying to copy a group into another group).
Thx
Crussell
The code I have so far is:
Code: Select all
global aryVideoList
global gVidModule
local scrollContainer
local sScrollerID
on preOpenCard
local tScrollerRect, tContentRect
if environment() is not "mobile" then
answer( "Only works on a mobile platform" )
else
lock screen
// Set up the 'master scroll container'
create group "scrollContainer"
set the width of it to 600
set the height of it to 800
set the location of it to (400, 800)
// Set up the group which holds the list of menu items
create group "grpOptions"
put 320 into xLoc
put 230 into yLoc
// Repeat 3 times to give enough content to exceed the master container
repeat 3 times
repeat for each key thisKey in aryVideoList
put aryVideoList[thisKey] into thisVideo
copy group "grpArrow" of card "objects" to group "grpOptions" of this card
set the name of it to thisVideo['sku']
put thisVideo['title'] into field "lblTitle" of it
put thisVideo['numvids'] & " videos" into field lblNumvids of it
if thisVideo['owned'] = "yes" then
put "View" into field "lblAction" of it
else
put "£" & thisVideo['price'] into field "lblAction" of it
end if
set the location of it to ( xLoc, yLoc )
put yLoc + 160 into yLoc
end repeat
end repeat
-- Copy the complete list of menu items into the master container
copy group "grpOptions" to group "scrollContainer"
set the visible of group "grpOptions" to true
put the left of group "grpOptions", the top of group "grpOptions", the formattedHeight of group "grpOptions" into tContentRect
mobileControlCreate "scroller", "menuScroll"
put the result into sScrollerID
mobileControlSet "menuScroll", "rect", tScrollerRect
mobileControlSet "menuScroll", "contentRect", tContentRect
mobileControlSet "menuScroll", "visible", true
mobileControlSet "menuScroll", "scrollingEnabled", true
mobileControlSet "menuScroll", "vindicator", true
mobileControlSet "menuScroll", "vscroll", 0
end if
end preOpenCard
on scrollerDidScroll hOffset, vOffset
//When user scrolls, scroll the group
set the vScroll of group "scrollContainer" to vOffset
end scrollerDidScroll