iOS scrolling text field. How?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: iOS scrolling text field. How?
Hi Todd,
Thanks for the tip. I've checked my code and confirmed I'm deleting the original scroller; however, the second time I create it it doesn't work properly.
I want to be able to update the scroller without changing cards, that's why I've put the setupMobileScroller in a separate function.
What am I missing here? It's driving me nuts. Works perfectly the first time, but when I try to delete and re-create it breaks.
Thanks,
Lars
--code--
on preopencard
setupMobileScroller
end preopencard
on setupMobileScroller
// setup mobile scroller UI
if environment() is not "mobile" then exit setupMobileScroller
put the rect of fld "namelist" into fldRect
put the formattedHeight of fld "namelist" into fldHeight
put the width of fld "namelist" into fldWidth
set the height of fld "namelist" to fldHeight
set the unboundedVScroll of group "scrollGroup" to true
if "myList" is in allControls then
iphoneControlDelete "myList"
end if
iphoneControlCreate "scroller", "myList"
//put the result into scrollid
iphoneControlSet "myList", "rect", fldRect
iphoneControlSet "myList", "contentRect", (0, 0, fldWidth, fldHeight)
iphoneControlSet "myList", "visible", "true"
iphoneControlSet "myList", "canBounce", "true"
iphoneControlSet "myList", "declerationRate", "fast"
iphoneControlSet "myList", "scrollingEnabled", "true"
iphoneControlSet "myList", "canScrollToTop", "true"
iphoneControlSet "myList", "canCancelTouches", "false"
iphoneControlSet "myList", "delayTouches", "true"
iphoneControlSet "myList", "vIndicator", "true"
iphoneControlSet "myList", "indicatorStyle", "black"
iphoneControlSet "myList", "indicatorInsets", "0,0,0,0"
iphoneControlSet "myList", "hscroll", 0
iphoneControlSet "myList", "vscroll", 0
repeat with count = 1 to the number of lines of fld "namelist"
set the textShift of line count of fld "namelist" to 0
end repeat
-- put the vScroll of group "scrollGroup" into fld 3
end setupMobileScroller
on closeCard
if environment() is not "mobile" then exit closeCard
iphoneControlDelete "myList"
end closeCard
on scrollerBeginDrag
--set the hilitedLine of fld 1 to empty
--put empty into fld 2
end scrollerBeginDrag
on scrollerScrollToTop
iphoneControlSet "myList", "vscroll", 0
end scrollerScrollToTop
on scrollerDidScroll hOffset, vOffset
set the vScroll of group "scrollGroup" to vOffset
-- put vOffset into fld 3
end scrollerDidScroll
--end code
Thanks for the tip. I've checked my code and confirmed I'm deleting the original scroller; however, the second time I create it it doesn't work properly.
I want to be able to update the scroller without changing cards, that's why I've put the setupMobileScroller in a separate function.
What am I missing here? It's driving me nuts. Works perfectly the first time, but when I try to delete and re-create it breaks.
Thanks,
Lars
--code--
on preopencard
setupMobileScroller
end preopencard
on setupMobileScroller
// setup mobile scroller UI
if environment() is not "mobile" then exit setupMobileScroller
put the rect of fld "namelist" into fldRect
put the formattedHeight of fld "namelist" into fldHeight
put the width of fld "namelist" into fldWidth
set the height of fld "namelist" to fldHeight
set the unboundedVScroll of group "scrollGroup" to true
if "myList" is in allControls then
iphoneControlDelete "myList"
end if
iphoneControlCreate "scroller", "myList"
//put the result into scrollid
iphoneControlSet "myList", "rect", fldRect
iphoneControlSet "myList", "contentRect", (0, 0, fldWidth, fldHeight)
iphoneControlSet "myList", "visible", "true"
iphoneControlSet "myList", "canBounce", "true"
iphoneControlSet "myList", "declerationRate", "fast"
iphoneControlSet "myList", "scrollingEnabled", "true"
iphoneControlSet "myList", "canScrollToTop", "true"
iphoneControlSet "myList", "canCancelTouches", "false"
iphoneControlSet "myList", "delayTouches", "true"
iphoneControlSet "myList", "vIndicator", "true"
iphoneControlSet "myList", "indicatorStyle", "black"
iphoneControlSet "myList", "indicatorInsets", "0,0,0,0"
iphoneControlSet "myList", "hscroll", 0
iphoneControlSet "myList", "vscroll", 0
repeat with count = 1 to the number of lines of fld "namelist"
set the textShift of line count of fld "namelist" to 0
end repeat
-- put the vScroll of group "scrollGroup" into fld 3
end setupMobileScroller
on closeCard
if environment() is not "mobile" then exit closeCard
iphoneControlDelete "myList"
end closeCard
on scrollerBeginDrag
--set the hilitedLine of fld 1 to empty
--put empty into fld 2
end scrollerBeginDrag
on scrollerScrollToTop
iphoneControlSet "myList", "vscroll", 0
end scrollerScrollToTop
on scrollerDidScroll hOffset, vOffset
set the vScroll of group "scrollGroup" to vOffset
-- put vOffset into fld 3
end scrollerDidScroll
--end code
Re: iOS scrolling text field. How?
Lars:
I never saw your attached stack in the previous post.
Could you attach it so I can get some context?
I'd be happy to look at it.
Thanks,
Todd
I never saw your attached stack in the previous post.
Could you attach it so I can get some context?
I'd be happy to look at it.
Thanks,
Todd
Re: iOS scrolling text field. How?
The MobGUI-plugin has a native scroller for drag and drop. Works nice, BUT as with this solution, dont work well when set to behave as an background. The scroll function just die when you access a card a second time (like go previous card). Tried for a week to make it work. It won't. Ready to join the give-up-club. 

Re: iOS scrolling text field. How?
Thanks for the feedback. Attached is the 2 card scroller app I was having issues with.
The issue was caused by not properly deleting the scroller when leaving the current card. It's working properly now on an application with multiple cards. I even got it to work properly on a single card with groups that are toggled between visible/invisible.
Thanks!
Re: iOS scrolling text field. How?
Lars..
You only have a 'scroller' on one of the cards, not both of them... I can get a scroller to work on one card without any problems. I have extended the example to two cards and now have a scroller on both cards....
On opening the stack in the iphone simulator, the scroller works, it also works on the second card the first time visited... however, on returning to the first card the scroller will not scroll... and yes, the scroller is being deleted on closing the card...
it's a problem...
Dixie
You only have a 'scroller' on one of the cards, not both of them... I can get a scroller to work on one card without any problems. I have extended the example to two cards and now have a scroller on both cards....
On opening the stack in the iphone simulator, the scroller works, it also works on the second card the first time visited... however, on returning to the first card the scroller will not scroll... and yes, the scroller is being deleted on closing the card...
it's a problem...
Dixie
- Attachments
-
- TwoScrollers.livecode.zip
- (3.22 KiB) Downloaded 422 times
-
- Posts: 1
- Joined: Sat Sep 10, 2011 1:42 pm
Re: multiple scrollers on same card
Hi,
Thanks for all the instrctive posts. They made me able to create a scrolling textfield. However, I would like to place 2 scrollable textfields on the same card. Is that possible ?
tnx,
Tanine
Thanks for all the instrctive posts. They made me able to create a scrolling textfield. However, I would like to place 2 scrollable textfields on the same card. Is that possible ?
tnx,
Tanine
Re: iOS scrolling text field. How?
Yes, it is. The key to doing this is to name your scrollers instead of relying on the ID. Check the release notes, there is an example.
This is a simpler way of keeping track of them for me.
Let us know how you succeed.
This is a simpler way of keeping track of them for me.
Let us know how you succeed.
Re: iOS scrolling text field. How?
hi! i hope this is the right place for this...
i have a scroller working very well in my stack (a remote reader for short stories from a website)
i resize the field every time i fill it with a new text and also when i change the font or the size of the chars of the field, it works (thanks again dixie)
but..i have two question
- how i can go to the top of the text? i tried with the set but it doesn't work, it's only a setting when the scroll is made?
- talking about fields, there's a way to get a webpage's content (with "get URL" etc) without have to fight against html codes like ! or ’" or ì ? (it this question belongs to another group just tell me)
thanks!
matteo
i have a scroller working very well in my stack (a remote reader for short stories from a website)
i resize the field every time i fill it with a new text and also when i change the font or the size of the chars of the field, it works (thanks again dixie)
but..i have two question
- how i can go to the top of the text? i tried with the
Code: Select all
iphoneControlSet sScrollerId, "vscroll", "0"
- talking about fields, there's a way to get a webpage's content (with "get URL" etc) without have to fight against html codes like ! or ’" or ì ? (it this question belongs to another group just tell me)
thanks!
matteo
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it
proudly hypertalking since 1989
proudly hypertalking since 1989
Re: iOS scrolling text field. How?
Hi,,,
Have a look at the 'canScrollToTop' property of the UIScrollView (page 58 of the iOS release notes).
be well
Dixie
Have a look at the 'canScrollToTop' property of the UIScrollView (page 58 of the iOS release notes).
be well
Dixie
Re: iOS scrolling text field. How?
already done, i've in the script making the scroller but i've the stack in full screen mode, so i hide the status bar on the top of the screen
iphoneControlSet set a scroller' property, so can't make the scroller do something, right?
--- solved: i simply rebuild the scroller, not so elegant but it works
another question: it's possible to get the viewable text of a field inside a scroller?
explained: i have to restore the scrolling of a field (which is part of a native scroller) so the reader can starts from the same point of the text even after he changes the font size or font type, i will get the vscroll of the scroller but i need to know what the user see on the top of the viewable part of the field
also, because lc don't "live" in background i need to restore the whole app every time the user pushes the home button and then return to the app
to do this, i write a file with all the information i need to do it, but i may also restore the text at the point the reader was before pushing the home button
so, i need a way to get the point of the text the user was and a way to get the user back there
any idea?
Code: Select all
iphoneControlSet sScrollerId, "canScrollToTop", "true"
iphoneControlSet set a scroller' property, so can't make the scroller do something, right?
--- solved: i simply rebuild the scroller, not so elegant but it works

another question: it's possible to get the viewable text of a field inside a scroller?
explained: i have to restore the scrolling of a field (which is part of a native scroller) so the reader can starts from the same point of the text even after he changes the font size or font type, i will get the vscroll of the scroller but i need to know what the user see on the top of the viewable part of the field
also, because lc don't "live" in background i need to restore the whole app every time the user pushes the home button and then return to the app
to do this, i write a file with all the information i need to do it, but i may also restore the text at the point the reader was before pushing the home button
so, i need a way to get the point of the text the user was and a way to get the user back there
any idea?
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it
proudly hypertalking since 1989
proudly hypertalking since 1989
Re: iOS scrolling text field. How?
Indeed… and one I have just run into. Is there a solution? I a looking at the project you posted. It works well, but if I add a card to your stack, go to it, when I come back to the original card the scroller no longer scrolls.Dixie wrote:Lars..
You only have a 'scroller' on one of the cards, not both of them... I can get a scroller to work on one card without any problems. I have extended the example to two cards and now have a scroller on both cards....
On opening the stack in the iphone simulator, the scroller works, it also works on the second card the first time visited... however, on returning to the first card the scroller will not scroll... and yes, the scroller is being deleted on closing the card...
it's a problem...
Dixie
My head is sore and my wall is dented.
Re: iOS scrolling text field. How?
Recently I have been opting to display data in a scrolling field primarily on a single card. Filtering the content and displaying it then checking to see how many lines are in it and then if needed setting the scroll to match the content. Perhaps you could do the same. You can even change the background etc and use special flip effects etc to make it look like you are going to a new card if that suits you. I personally like to keep as much data as possible in one field and filter it and then display it. Lately in the form of Index, sub index, sub sub index.
A Typical 4 card stack layout for me:
Card 1: Provide a main index and sub index choices via scrolling lists. Sometimes also display HTMl, PDF's, video etc.
Card 2: Display Data Selected on card 1 or perhaps be a hidden card that does calculations etc that the user never sees.
Card 3: Settings. User Settings that will be saved to a text file as needed and on close stack
Card 4" Info page. Usually have a scrolling field here also explaining how to use the app, and possibly display a how to use app video
I don't have a problem deleting the scroller and re establishing it when I go back to the card if required, however it is time consuming and a performance issue. So I prefer to stay on the card with the scroller established and bring the data to the scrolling field rather than delete the scroller open a new card and start all over. Just an idea that might work for your situation. It seems that new coders want to create a card for each data instance but sometimes better i think to just have a handful of cards and bring the data, photos, HTML, video, etc to the card.
Hope this helps.
Dave
Dave
A Typical 4 card stack layout for me:
Card 1: Provide a main index and sub index choices via scrolling lists. Sometimes also display HTMl, PDF's, video etc.
Card 2: Display Data Selected on card 1 or perhaps be a hidden card that does calculations etc that the user never sees.
Card 3: Settings. User Settings that will be saved to a text file as needed and on close stack
Card 4" Info page. Usually have a scrolling field here also explaining how to use the app, and possibly display a how to use app video
I don't have a problem deleting the scroller and re establishing it when I go back to the card if required, however it is time consuming and a performance issue. So I prefer to stay on the card with the scroller established and bring the data to the scrolling field rather than delete the scroller open a new card and start all over. Just an idea that might work for your situation. It seems that new coders want to create a card for each data instance but sometimes better i think to just have a handful of cards and bring the data, photos, HTML, video, etc to the card.
Hope this helps.
Dave
Dave
Re: iOS scrolling text field. How?
Actually, this project uses only one scroller on one card to display a rather limited data set (the items of a restaurant menu). Other cards in the stack display other info that is more graphical in nature.
I have posted two files in: http://nomisses.com/stuff/scrollers.zip
One is based on Dixie's example that scrolls a field, and the other is based on the LC example stack that scrolls graphics. I have added a button in the lower left corner of each to go to a blank card.
Both projects delete the scroller on closecard, and build it on opencard. When going to the next card and then back, the scroller in Dixie's stack is broken, but this is not the case with the LC example.
I'd really like to understand what the difference is here. Hopefully someone can enlighten me.
Thanks.
I have posted two files in: http://nomisses.com/stuff/scrollers.zip
One is based on Dixie's example that scrolls a field, and the other is based on the LC example stack that scrolls graphics. I have added a button in the lower left corner of each to go to a blank card.
Both projects delete the scroller on closecard, and build it on opencard. When going to the next card and then back, the scroller in Dixie's stack is broken, but this is not the case with the LC example.
I'd really like to understand what the difference is here. Hopefully someone can enlighten me.
Thanks.
Re: iOS scrolling text field. How?
Hi…
You are correct, I have been unable to make scrollers work of different cards when they are scrolling text fields… Well, the scroll will work on the first card and for the first time on the second card that uses a scroller to scroll a text field… it does then 'break', as you put it… and on returning to the first card the scroller then does not want to play nicely at all…
However, using the same structure to build the scrollers on different cards I have no problem scrolling anything else on multiple cards and alternating between them, except with text fields… Also, having a textfield being scrolled on one card and images or groups on the second card and alternating between the two does not cause a problem...
be well,
Dixie
You are correct, I have been unable to make scrollers work of different cards when they are scrolling text fields… Well, the scroll will work on the first card and for the first time on the second card that uses a scroller to scroll a text field… it does then 'break', as you put it… and on returning to the first card the scroller then does not want to play nicely at all…
However, using the same structure to build the scrollers on different cards I have no problem scrolling anything else on multiple cards and alternating between them, except with text fields… Also, having a textfield being scrolled on one card and images or groups on the second card and alternating between the two does not cause a problem...
be well,
Dixie
Re: iOS scrolling text field. How?
After some head scratching, I have arrived at a working solution. Note that I am not sure just exactly what the glitch was in your example. As debugging LC for iOS is pretty much non-existant, I just chose to use the larger hammer of redoing it from scratch rather than trying to isolate the initial problem.
Code: Select all
local myScroller
on preOpenCard
if the environment is not "mobile" then
exit preOpenCard
end if
--make sure the object to scroll is the right size to fit the content
set the height of fld "menu" to the formattedheight of fld "menu"
set the unboundedHScroll of group "scrollGroup" to true
set the unboundedVScroll of group "scrollGroup" to true
iphoneControlCreate "scroller"
put the result into myScroller
iphoneControlSet myScroller, "rect", the rect of group "scrollGroup"
--contentRect should match the actual content size of the object
iphoneControlSet myScroller, "contentRect", (0, 0, the width of fld 1, the formattedHeight of fld 1)
iphoneControlSet myScroller, "visible", "true"
iphoneControlSet myScroller, "canBounce", "true"
iphoneControlSet myScroller, "pagingEnabled", "false"
iphoneControlSet myScroller, "canScrollToTop", "true"
resizeStack
end preOpenCard
on closeCard
if the environment is not "mobile" then
exit closeCard
end if
iphoneControlDelete myScroller
end closeCard
on resizeStack
if the environment is not "mobile" then
exit resizeStack
end if
set the hScroll of group "scrollGroup" to 0
set the vScroll of group "scrollGroup" to 0
iphoneControlSet myScroller, "rect", the rect of group "scrollGroup"
iphoneControlSet myScroller, "hscroll", 0
iphoneControlSet myScroller, "vscroll", 0
end resizeStack
on scrollerDidScroll pOffsetX, pOffsetY
lock screen
set the hScroll of group "scrollGroup" to pOffsetX
set the vScroll of group "scrollGroup" to pOffsetY
unlock screen
end scrollerDidScroll