vScroll & native IOS scroller
Moderators: heatherlaine, kevinmiller, robinmiller, malte, splash21
vScroll & native IOS scroller
Question,
I have a small program that uses a native ios scroller with around 20 buttons that reside inside. when a button is clicked, it takes me to another screen and the user chooses an option which brings you back to the scroller. My question is this....if the user scrolls down with the scroller and chooses a button, (which takes you to the next screen) and then comes back, the slider position is not saved and the user has to scroll back down to where they were....its kind of annoying. I have attempted to use the vScroll to obtain the position of the scroller when I exit the card and load the last position when the card re-opens. So far, when I set the position of the scroller with the vScroll, it offsets the scroller and appears to simply drop the positon of the entire scroller insead of moving the scroller back to where the user left off. I am wondering if there is another way to accomplish having the scroller positon saved so when the user comes back to the card the scroller is in the last place they scrolled to. Sorry if this is confusing....
I have a small program that uses a native ios scroller with around 20 buttons that reside inside. when a button is clicked, it takes me to another screen and the user chooses an option which brings you back to the scroller. My question is this....if the user scrolls down with the scroller and chooses a button, (which takes you to the next screen) and then comes back, the slider position is not saved and the user has to scroll back down to where they were....its kind of annoying. I have attempted to use the vScroll to obtain the position of the scroller when I exit the card and load the last position when the card re-opens. So far, when I set the position of the scroller with the vScroll, it offsets the scroller and appears to simply drop the positon of the entire scroller insead of moving the scroller back to where the user left off. I am wondering if there is another way to accomplish having the scroller positon saved so when the user comes back to the card the scroller is in the last place they scrolled to. Sorry if this is confusing....
Re: vScroll & native IOS scroller
let's try it this way since there has been no response. I have included my stack for anyone who wants to tell me why my scroller will not return back to the last scrolled position when returning. Thanks in advance...
-
- VIP Livecode Opensource Backer
- Posts: 7238
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: vScroll & native IOS scroller
I didn't actually look at your stack, but what I do is just set up everything from scratch each time the card opens. Set the vScroll of the field to 0, create the scroller, then set the vScroll of both the field and the scroller to the value you've saved.
If you don't change it, the LiveCode field will retain its old scroll when you return to the card, which means you can just read that instead of saving the setting. Get the scroll, then reset everything to 0, then reset the scroll(s) to what it was. That's what this does (ignore the naming conventions, I was passing different field names to the handler):
The handler assumes the native scroller is deleted on closecard, which is why it just makes a new one.
If you don't change it, the LiveCode field will retain its old scroll when you return to the card, which means you can just read that instead of saving the setting. Get the scroll, then reset everything to 0, then reset the scroll(s) to what it was. That's what this does (ignore the naming conventions, I was passing different field names to the handler):
Code: Select all
on makeScroller pName
put pName & "List" into tGrpFld
set the layerMode of fld tGrpFld to "scrolling"
put the vScroll of fld tGrpFld into tOldScroll -- here's where it reads the saved scroll value
set the vScroll of fld tGrpFld to 0
mobileControlCreate "scroller", pName
mobileControlSet pName, "rect", the rect of fld tGrpFld
mobileControlSet pName, "contentRect",(0,0,the width of fld tGrpFld,the formattedHeight of fld tGrpFld)
mobileControlSet pName, "visible","true"
mobileControlSet pName, "opaque","false"
mobileControlSet pName, "vscroll",0
-- iOS only:
mobileControlSet pName, "canBounce", true
mobileControlSet pName, "delayTouches", true
set the vScroll of fld tGrpFld to tOldScroll
mobileControlSet pName, "vscroll",tOldScroll
end makeScroller
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: vScroll & native IOS scroller
I appreciate very much your time and response to my issue, but sadly I don't know quite enough about manipulating your code to make this work for me. I am starting to assume that I need to get rid of mobGUI and start over. In concept, the mobGUI scroller works, but I find trying to make changes to the group just screws things up for me. Most likely it is not the program but the fault of the programmer (me). I have gone through the tutorials on how to create a scrolling field, but fall short when trying to create a group of buttons within a field that scrolls. I am a rookie when it comes to LiveCode and understand my limitations, that is why I purchased mobGUI thinking it would take some of the work out of learning the coding process. I have reverted back to actually reading the entire manual, (imagine that), in order to get a better grasp on LC. I am going to play around with what you have provided some more, but I fear I am going to need to start over and salvage most of the code I have already written...Thanks again for your help.
-
- VIP Livecode Opensource Backer
- Posts: 7238
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: vScroll & native IOS scroller
I see, I didn't know you were using MobGUI. I don't use it, but isn't there a property you can set to control the scroll position? Seems like there should be.
Since you're using a group, get the vScroll of the group and use that to control the vScroll of the scroller. I'd hate to see you have to rewrite all your code, though reading the whole manual is a noble goal.
Since you're using a group, get the vScroll of the group and use that to control the vScroll of the scroller. I'd hate to see you have to rewrite all your code, though reading the whole manual is a noble goal.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: vScroll & native IOS scroller
this is the mobgui forumjacque wrote:I see, I didn't know you were using MobGUI.
Re: vScroll & native IOS scroller
Kenny,
Have you checked the documentation at mobgui dot com? As well as the page for the scroller, check the page "New commands for iOS native controls", which shows how to set properties of the MobGUI controls. That is, how to set (and get) any of the native iOS properties, using MobGUI syntax.
As an aside, I spent quite a while struggling with MobGUI. I started with the same goal that you mention: aiming to circumvent time spent learning how to do things directly in LiveCode. I have since realised this isn't the right approach. You really do need to go through the effort of getting to grips with how to create iOS scrollers, etc. in script and understand how it all works. Then you can resume using MobGUI for situations where it saves some effort, but only where you know what it is doing. It can save time, for example, creating buttons, etc. and even sometimes scrollers. But you should only use it where you know how to do it in script, but want to save time.
Cheers,
Adrian
Have you checked the documentation at mobgui dot com? As well as the page for the scroller, check the page "New commands for iOS native controls", which shows how to set properties of the MobGUI controls. That is, how to set (and get) any of the native iOS properties, using MobGUI syntax.
As an aside, I spent quite a while struggling with MobGUI. I started with the same goal that you mention: aiming to circumvent time spent learning how to do things directly in LiveCode. I have since realised this isn't the right approach. You really do need to go through the effort of getting to grips with how to create iOS scrollers, etc. in script and understand how it all works. Then you can resume using MobGUI for situations where it saves some effort, but only where you know what it is doing. It can save time, for example, creating buttons, etc. and even sometimes scrollers. But you should only use it where you know how to do it in script, but want to save time.
Cheers,
Adrian
-
- VIP Livecode Opensource Backer
- Posts: 7238
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: vScroll & native IOS scroller
Yeah, I noticed that later. This isn't the first time I've done that. When I read the forums in my Android RSS reader it doesn't list the forum name at the top of the message. I wish they'd turn on the email option, but that's a whole other topic.shaosean wrote:this is the mobgui forumjacque wrote:I see, I didn't know you were using MobGUI.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: vScroll & native IOS scroller
Thanks everyone for responding....I am going to check on some things and play around with scroller later...hopefully I can get a handle on this sooner or later.
Re: vScroll & native IOS scroller
I looked at the documentation on the website and have to say that there is a lack of supporting docs regarding the new iOS commands. I'm sure they do what I need, but actually knowing what syntax to use with them is another thing entirely! It seems mobgui assumes you already know what your doing ,so no need for explanation....I'm frustratedAdrian wrote:Kenny,
Have you checked the documentation at mobgui dot com? As well as the page for the scroller, check the page "New commands for iOS native controls", which shows how to set properties of the MobGUI controls. That is, how to set (and get) any of the native iOS properties, using MobGUI syntax.
As an aside, I spent quite a while struggling with MobGUI. I started with the same goal that you mention: aiming to circumvent time spent learning how to do things directly in LiveCode. I have since realised this isn't the right approach. You really do need to go through the effort of getting to grips with how to create iOS scrollers, etc. in script and understand how it all works. Then you can resume using MobGUI for situations where it saves some effort, but only where you know what it is doing. It can save time, for example, creating buttons, etc. and even sometimes scrollers. But you should only use it where you know how to do it in script, but want to save time.
Cheers,
Adrian