Smooth scrolling text field

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
richardmac
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 211
Joined: Sun Oct 24, 2010 12:13 am

Smooth scrolling text field

Post by richardmac » Sat Dec 31, 2011 9:23 pm

I'm working on the iPhone version of our "HAT" app, and taking advantage of some of the native iOS stuff. For one field where users type text in, I've switched from the traditional ugly motif LiveCode field to the iOS multiline, and it is AWESOME. Everything works flawlessly.

So now I'm working on the "about" screen, which is a big long scrolling text field. I'd like to use the iOS multiline object, but it needs to be read only. However, nothing I've tried makes my multiline object read-only.

Here's the code:

Code: Select all

  iphoneControlCreate "multiline", "daScroll"
   # set the native text input field to the size and position of the graphic input rectangle
   iphoneControlSet "daScroll",the rect of image "my border"
   iphoneControlSet "daScroll", "visible", true
   iphoneControlSet "daScroll", "text", field "about us content"
   iphoneControlSet "editing","read-only"
   iphoneControlSet "editable","read"
This creates an iOS multiline text area that is drawn exactly where I want it on the screen, and then puts the contents of our about field into the text area. That works perfectly. But the user can edit it. I want it to be read only. I tried setting the "editing" property and the "editable" property but they do nothing. I'd love to be told my syntax is wrong, get the correct syntax, and have this work!

Before anyone suggests using the scroller object instead, I know I can do that. But here's the thing - we're doing this for the retina display iPhone, and the about text is in size 22 point font, so it's still kinda small on the retina screen. And when you use the scroller idea, as is used in the example stack, the scrolling is NOT SMOOTH. You don't notice it so much on a picture, but on a small font on the retina display you really notice it. On the other hand, the multiline scrolling is flawless.

Any help appreciated.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Smooth scrolling text field

Post by Dixie » Sat Dec 31, 2011 9:52 pm

richardmac...

You have scripted iphoneControlSet "editable","read"
'editable' needs a boolean value... ie... either 'true' or 'false'. That being the case you don't need to set the 'editing' property.

be well

Dixie

PS... don't forget to set the idOrName... as in iphoneControlSet idOrName, property, value

richardmac
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 211
Joined: Sun Oct 24, 2010 12:13 am

Re: Smooth scrolling text field

Post by richardmac » Sat Dec 31, 2011 10:09 pm

Dixie,

THANKS! That was it, all right. It's working perfectly now. :)

richardmac
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 211
Joined: Sun Oct 24, 2010 12:13 am

Re: Smooth scrolling text field

Post by richardmac » Sat Dec 31, 2011 10:14 pm

You can set the name when you create the object - so this line:

iphoneControlCreate "multiline", "daScroll"

...creates the object and names it "daScroll."

As an aside - for anyone dealing with text fields, whether scrolling or editable - you need to use multiline. It works awesome and it gives you all the cool native text elements like auto capitalize, spell check, and so on.

One interesting thing I discovered - In the same script above, it works great for the iPhone 3, but on an iPhone 4 or iPod Touch with Retina display, the area you specify ends up being off, and you have to compensate by putting in the rect manually. Either that or I'm doing it wrong. Which is very possible.

Post Reply