iOS scrolling text field. How?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 222
- Joined: Wed Jun 21, 2006 7:33 pm
- Location: West of the Pecos
- Contact:
iOS scrolling text field. How?
I have a bunch of text I want to display in a locked text field that the user needs to be able to scroll up or down as desired. If I use a scrolling field from LiveCode, it -does- work (I think) but the look/feel is Motif(?) rather than native iOS.
Is there a solution short of diving into Xcode? I'm rather miffed that I spent all this $$ on LiveCode + iOS + Apple Developer and find that native text fields are MIA.
Perhaps there's a stack which contains the appropriate field (group?) and I can simply copy and paste it into my app?
Thanks,
Barry
Is there a solution short of diving into Xcode? I'm rather miffed that I spent all this $$ on LiveCode + iOS + Apple Developer and find that native text fields are MIA.
Perhaps there's a stack which contains the appropriate field (group?) and I can simply copy and paste it into my app?
Thanks,
Barry
-
- Posts: 222
- Joined: Wed Jun 21, 2006 7:33 pm
- Location: West of the Pecos
- Contact:
Re: iOS scrolling text field. How?
In the "Mobile Scroller Example" stack, there's a group (which appears to be just four photos grouped together and named "Image Scroller"). It appears that all the magic is happening through the card script:
-- Create the scroller and store its id
iphoneControlCreate "scroller"
put the result into sScrollerId
-- The 'rect' is the region of the card it should cover
iphoneControlSet sScrollerId, "rect", the rect of group "Image Scroller"
-- The 'contentRect' is the region the scroller scrolls over
iphoneControlSet sScrollerId, "contentRect", (0, 0, 1600, 1200)
-- The 'visible' determines if the scroller is displayed
iphoneControlSet sScrollerId, "visible", "true"
-- The 'canBounce' determines whether the standard iOS 'bouncing' occurs
-- at extremities of scrolling
iphoneControlSet sScrollerId, "canBounce", "false"
-- The 'pagingEnabled' determines whether scrolling only happens in multiples
-- of the width/height
iphoneControlSet sScrollerId, "pagingEnabled", "false"
-- The 'canScrollToTop' determines whether touching the status bar scrolls
-- the scroller to the top
iphoneControlSet sScrollerId, "canScrollToTop", "true"
...and a bunch more stuff, as well.
The problem is that I can see nothing in any LiveCode documentation along the lines of "iPhoneControlCreate" or "iPhoneControlSet" nor do I see any user-created handlers so how is that command (function?) being handled? I'm looking for anything else in that stack that might provide the magic but I'm stumped.
Barry
-- Create the scroller and store its id
iphoneControlCreate "scroller"
put the result into sScrollerId
-- The 'rect' is the region of the card it should cover
iphoneControlSet sScrollerId, "rect", the rect of group "Image Scroller"
-- The 'contentRect' is the region the scroller scrolls over
iphoneControlSet sScrollerId, "contentRect", (0, 0, 1600, 1200)
-- The 'visible' determines if the scroller is displayed
iphoneControlSet sScrollerId, "visible", "true"
-- The 'canBounce' determines whether the standard iOS 'bouncing' occurs
-- at extremities of scrolling
iphoneControlSet sScrollerId, "canBounce", "false"
-- The 'pagingEnabled' determines whether scrolling only happens in multiples
-- of the width/height
iphoneControlSet sScrollerId, "pagingEnabled", "false"
-- The 'canScrollToTop' determines whether touching the status bar scrolls
-- the scroller to the top
iphoneControlSet sScrollerId, "canScrollToTop", "true"
...and a bunch more stuff, as well.
The problem is that I can see nothing in any LiveCode documentation along the lines of "iPhoneControlCreate" or "iPhoneControlSet" nor do I see any user-created handlers so how is that command (function?) being handled? I'm looking for anything else in that stack that might provide the magic but I'm stumped.
Barry
-
- Posts: 222
- Joined: Wed Jun 21, 2006 7:33 pm
- Location: West of the Pecos
- Contact:
Re: iOS scrolling text field. How?
A-ha! I just found the LiveCode notes where the experimental iOS native controls are mentioned (page 36 of LiveCodeNotes-4_6_0-iOS.pdf). Guess we'll see something in the actual Documentation window down the road. I'll have to play with this control layered over a text field and see how it goes.
Barry
Barry
-
- Posts: 222
- Joined: Wed Jun 21, 2006 7:33 pm
- Location: West of the Pecos
- Contact:
Re: iOS scrolling text field. How?
Well, placed a scrolling text field onto the card, altered the script to refer to the field (and even made the field 5500 pixels tall). No success. I'll keep trying but this is something that really needs an official solution/workaround from RunRev.
The notes (PDF) on this topic are written by an alpha-geek for alpha-geeks and the scrolling example stack is bereft of any usable documentation.
What we need is a stack (intended for iOS) that shows how to scroll a field of text and good set of instructions (maybe comments in the script?).
Thanks for any advice, example stacks, etc. that anyone might provide.
Barry
The notes (PDF) on this topic are written by an alpha-geek for alpha-geeks and the scrolling example stack is bereft of any usable documentation.
What we need is a stack (intended for iOS) that shows how to scroll a field of text and good set of instructions (maybe comments in the script?).
Thanks for any advice, example stacks, etc. that anyone might provide.
Barry
-
- Livecode Opensource Backer
- Posts: 1336
- Joined: Sun Jul 12, 2009 10:53 am
- Location: Bordeaux, France
Re: iOS scrolling text field. How?
Barry...
I have attached an stack showing scrolling text. All the script handlers are in the card... I haven't had time to comment the scripts, but if you have any questions... well, just post them
be well
Dixie
I have attached an stack showing scrolling text. All the script handlers are in the card... I haven't had time to comment the scripts, but if you have any questions... well, just post them
be well
Dixie
- Attachments
-
- LCScroller.livecode.zip
- (2.61 KiB) Downloaded 530 times
-
- Posts: 222
- Joined: Wed Jun 21, 2006 7:33 pm
- Location: West of the Pecos
- Contact:
Re: iOS scrolling text field. How?
Thank you for the example. I'll be coding this PM and I'll check it out then. I appreciate your guidance.
Barry
Barry
-
- Posts: 222
- Joined: Wed Jun 21, 2006 7:33 pm
- Location: West of the Pecos
- Contact:
Re: iOS scrolling text field. How?
A-ha! I think I understand it now.
Dixie: Your stack was helpful. I also examined some examples posted by others (including what RunRev provides) but what was missing (not working in my stacks) I finally guessed at and probably just got lucky.
It appears that the code is what generates the scroller during runtime. The "group" named Scroller (or something like that in all the stacks I've examined) seems to be simply a field (or picture/pictures) that's been grouped - in the case of a simple scrolling text field, grouped to nothing but itself. Once I did that (and named it to match what the card script uses), the scrolling took place (in the simulator) exactly as expected.
I'm much happier now knowing a native scroller is available; that Motif-styled scrollbar of a standard scrolling field is an abomination on iOS.
Thanks again for your assistance.
Barry
Dixie: Your stack was helpful. I also examined some examples posted by others (including what RunRev provides) but what was missing (not working in my stacks) I finally guessed at and probably just got lucky.
It appears that the code is what generates the scroller during runtime. The "group" named Scroller (or something like that in all the stacks I've examined) seems to be simply a field (or picture/pictures) that's been grouped - in the case of a simple scrolling text field, grouped to nothing but itself. Once I did that (and named it to match what the card script uses), the scrolling took place (in the simulator) exactly as expected.
I'm much happier now knowing a native scroller is available; that Motif-styled scrollbar of a standard scrolling field is an abomination on iOS.
Thanks again for your assistance.
Barry
-
- Posts: 65
- Joined: Thu Oct 07, 2010 4:47 pm
Re: iOS scrolling text field. How?
Dixie,
Thank you so much for the sample code and explanations. I was wondering if you knew why the scrolling of the field does not seem smooth like the true native scrolling field control on an iOS device. Are there any settings that can be applied to try to make the scroll operate more smoothly?
Thanks in advance,
Ezra
Thank you so much for the sample code and explanations. I was wondering if you knew why the scrolling of the field does not seem smooth like the true native scrolling field control on an iOS device. Are there any settings that can be applied to try to make the scroll operate more smoothly?
Thanks in advance,
Ezra
-
- Posts: 222
- Joined: Wed Jun 21, 2006 7:33 pm
- Location: West of the Pecos
- Contact:
Re: iOS scrolling text field. How?
I'm having a devil of a time understanding why my stack's scrollgroup starts out scrolled and can't be scrolled back to "0". I've got to believe I've set something wrong in the card script. I'm using Dixie's sample stack she was kind enough to post in this thread some time ago. I've attached the stack. Would someone who has the iOS kit mind looking at it and telling me where I screwed up?
Thanks in advance!
Barry
Thanks in advance!
Barry
-
- Livecode Opensource Backer
- Posts: 1336
- Joined: Sun Jul 12, 2009 10:53 am
- Location: Bordeaux, France
Re: iOS scrolling text field. How?
rumplestiltskin...
I don't have time right now to comment the card script, but I have ammended your stack, it now scrolls to the top.
be well,
Dixie
I don't have time right now to comment the card script, but I have ammended your stack, it now scrolls to the top.
be well,
Dixie
- Attachments
-
- iAdlib fix.livecode.zip
- (4.85 KiB) Downloaded 378 times
-
- Posts: 222
- Joined: Wed Jun 21, 2006 7:33 pm
- Location: West of the Pecos
- Contact:
Re: iOS scrolling text field. How?
Dixie,
Thanks very much for your assistance. I added some height to the stack to make it match the size of the iPad (although I'm not 100% I should be setting the rect of the stack to 1024x768). I then had to use a specific field rect (instead of taking the existing rect of the field) in order to get things to line up the way I wanted. I think I'll have to do that and not rely upon the rects as they exist in the stack as grouping the field results in a rect that is somewhat different than the rect of the field. I don't see why this should be; looks like a bug to me. (Why should a field that is grouped to nothing else result in a group that is anything other than the size of the field? - That's something I'll have to ask RunRev.)
Now I have to compare the script of the card that works (your "fix" stack) to the one I uploaded and see where I goofed up.
But it now works and I'm a happy camper. Thanks!
Barry
Thanks very much for your assistance. I added some height to the stack to make it match the size of the iPad (although I'm not 100% I should be setting the rect of the stack to 1024x768). I then had to use a specific field rect (instead of taking the existing rect of the field) in order to get things to line up the way I wanted. I think I'll have to do that and not rely upon the rects as they exist in the stack as grouping the field results in a rect that is somewhat different than the rect of the field. I don't see why this should be; looks like a bug to me. (Why should a field that is grouped to nothing else result in a group that is anything other than the size of the field? - That's something I'll have to ask RunRev.)
Now I have to compare the script of the card that works (your "fix" stack) to the one I uploaded and see where I goofed up.
But it now works and I'm a happy camper. Thanks!
Barry
-
- VIP Livecode Opensource Backer
- Posts: 3990
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: iOS scrolling text field. How?
Barry,
If you look at the group in the property inspector and choose Text Formatting at the bottom you will see margins. Set that to 0 and the group will have the same size as the field it encloses. (provided you don't set the Showborder to true, that would add the borderwidth to the rect of the group)
Have a look at margins in the dictionary.
Kind regards
Bernd
it is not a bug. A group has a default margin of 4. That means if you group a field the group will have 4 pixel added on each of the 4 sides.and not rely upon the rects as they exist in the stack as grouping the field results in a rect that is somewhat different than the rect of the field
If you look at the group in the property inspector and choose Text Formatting at the bottom you will see margins. Set that to 0 and the group will have the same size as the field it encloses. (provided you don't set the Showborder to true, that would add the borderwidth to the rect of the group)
Have a look at margins in the dictionary.
Kind regards
Bernd
-
- Posts: 222
- Joined: Wed Jun 21, 2006 7:33 pm
- Location: West of the Pecos
- Contact:
Re: iOS scrolling text field. How?
Bernd,
Thanks for the heads-up regarding margins!
Barry
Thanks for the heads-up regarding margins!
Barry
Re: iOS scrolling text field. How?
Hi guys,
Super helpful example and I've been able to get it working on a stack with only 1 card; however, on a stack with multiple cards I can't get it to work after switching to another card.
I've attached an updated version of the LCScroller. If you run it you'll find the scroller on the first card works correctly, but when you switch to the second card and back, the scroller no longer works properly.
I'm trying to create an app with multiple cards and multiple scrolling text fields.
Any advice?
Many thanks,
Lars
Super helpful example and I've been able to get it working on a stack with only 1 card; however, on a stack with multiple cards I can't get it to work after switching to another card.
I've attached an updated version of the LCScroller. If you run it you'll find the scroller on the first card works correctly, but when you switch to the second card and back, the scroller no longer works properly.
I'm trying to create an app with multiple cards and multiple scrolling text fields.
Any advice?
Many thanks,
Lars
-
- VIP Livecode Opensource Backer
- Posts: 243
- Joined: Sun Dec 06, 2009 12:24 am
- Location: Fredericktown, MO
- Contact:
Re: iOS scrolling text field. How?
Make sure you delete the scrollers you create each time you leave the card.
See the iOS release notes for deleting native controls.
Hope that helps.
Todd
See the iOS release notes for deleting native controls.
Hope that helps.
Todd