Can't get to create a native scrolling text field

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Can't get to create a native scrolling text field

Post by Mag » Mon Jan 20, 2014 12:37 pm

Hi all,

I'm trying to create a native text scrolling field that work on Android. The field is created but you can't scroll it. Works fine on iOS, not in Android. Here is the code I'm using.

Code: Select all

on openCard
   createNativeField
end openCard

on createNativeField
   if environment() = "mobile" then
      mobileControlCreate "multiline", "testField"
      
      mobileControlSet "testField", "rect", the rect of graphic "testFieldGraphic"
      mobileControlSet "testField", "text", field "sourceField"
      
      mobileControlSet "testField", "visible", "true"
      mobileControlSet "testField", "editable", "false"
      
      mobileControlSet "testField", "dataDetectorTypes", "link"
      mobileControlSet "testField", "textAlign", "center"
      mobileControlSet "testField", "fontSize", "16"
      
      mobileControlSet "testField", "autoCorrectionType", "no"
      mobileControlSet "testField", "scrollingEnabled", "true"
      
      mobileControlSet "testField", "opaque", "false"
      mobileControlSet "testField", "scrollingEnabled", "true"
      
      if the platform is "iphone" then
         mobileControlSet "testField", "borderStyle", "none"
         mobileControlSet "testField", "indicatorStyle", "white"
         mobileControlSet "testField", "canBounce", "true"
         mobileControlSet "testField", "canScrollToTop", "true"
      end if
      
      if the platform is "android" then
         mobileControlSet "testField", "multiline", "true"
      end if
      
   end if
end createNativeField


Here is the test stack
Attachments
Untitled 1.livecode.zip
(2.06 KiB) Downloaded 261 times

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Can't get to create a native scrolling text field

Post by Klaus » Mon Jan 20, 2014 4:24 pm

HI Mag,

your script will only CREATE that scroller and nothing else :D

You need another handler "scrollerDidScroll" to add the actual scrolling functionality:

Code: Select all

on scrollerDidScroll tHScroll, tVScroll
   set the VScroll of fld "your field 2B scrolled here" to tVScroll
  ## or whatever you want to scroll
end scrollerDidScroll
Best

Klaus

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Can't get to create a native scrolling text field

Post by jacque » Mon Jan 20, 2014 6:54 pm

Here are the commands I use to create a multiline input field that scrolls on both iOS and Android:

Code: Select all

  mobileControlCreate "multiline", "displayInput"
  mobileControlSet "displayInput", "rect", the rect of fld "display"
  mobileControlSet "displayInput", "vScroll", "0"
  mobileControlSet "displayInput", "visible", "true"
  mobileControlSet "displayInput", "text", fld "display"
  mobileControlSet "displayInput", "autocorrectionType", "no"
  -- iOS only:
  mobileControlSet "displayInput", "editable", "false"
  mobileControlSet "displayInput", "scrollingEnabled", true
  mobileControlSet "displayInput", "enabled", true
You don't need to distinguish between iOS and Android for the iOS-only properties, they will just be ignored on Android.

(Klaus, he isn't using a scroller, he's using a native input control, so it shouldn't require any scripted scrolling.)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Can't get to create a native scrolling text field

Post by Mag » Tue Jan 21, 2014 10:44 am

Hi Klaus, thank you for the code I will use it when implementing a scroller!

Hi jacque, I will try it right now!

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Can't get to create a native scrolling text field

Post by Klaus » Tue Jan 21, 2014 1:19 pm

jacque wrote:(Klaus, he isn't using a scroller, he's using a native input control, so it shouldn't require any scripted scrolling.)
Oh, well yes, sorrry, my fault. 8)

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Can't get to create a native scrolling text field

Post by Mag » Thu Jan 23, 2014 3:15 pm

It works.

The problem the field has are:

- I'ts editable. I use it to show credits so it's better to avoid this.
- On Kindle about every word is underlined in red
- Links are not clickable

:oops:

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Can't get to create a native scrolling text field

Post by jacque » Thu Jan 23, 2014 4:58 pm

Yes, I had the same problems. The red underline is a user preferences setting, it means that spell checking is turned on. You can't really control that. The editable property on Android has been deprecated and no longer works except in older versions of Android. I'm not sure about the links, I wasn't using those, but I think there's a property you can set to enable them.

Since you are just displaying static text I think the best solution is to just use a LC field and lay a native scroller over it. That means that Klaus was right after all. :-)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Can't get to create a native scrolling text field

Post by Mag » Fri Jan 24, 2014 1:37 am

jacque wrote:Yes, I had the same problems. The red underline is a user preferences setting, it means that spell checking is turned on. You can't really control that. The editable property on Android has been deprecated and no longer works except in older versions of Android. I'm not sure about the links, I wasn't using those, but I think there's a property you can set to enable them.

Since you are just displaying static text I think the best solution is to just use a LC field and lay a native scroller over it. That means that Klaus was right after all. :-)
Great advice. Is there some trick to make the field large enough to show all the text? I've a lot of text to put inside and it's a bit difficult to enlarge the stack manually to set the field dimension correctly... :roll:

PS
Oh, yes, the foresight of that guy is known all over the world!

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Can't get to create a native scrolling text field

Post by Mag » Fri Jan 24, 2014 1:51 am

Oops, sorry, maybe I have just to use the Fit Content button on the Inspector... :mrgreen:

Post Reply