iOS copy paste

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
gstarox
Posts: 14
Joined: Sun Apr 12, 2020 3:31 am

iOS copy paste

Post by gstarox » Sat Apr 25, 2020 3:26 pm

I want to be able to for my iphone app users to copy and paste multiline text to/from another app e.g. iPhone Notes
Sample text is in the format of multi-lined comma-separated values:
Push-ups, Full
Plank, Core
Squats, Legs


I've tried searching for ways to do this, a lot of forum posts seem quite old, so I just want to clarify what I've seen on them is still relevant and what I've tested is correct

My understanding is:
1. There is no copy/paste function from the Livecode fields on iphone, you have to use an iOS Native field (mobileControlCreate etc.)
2. There is no iOS Native field widget (unlike Android) and there's no information about there being one in development
3. I can't create a button that will just access whatever's on the iPhone clipboard and put it into one of my fields
4. I found that on my iPhone I could paste into an Ask/Answer Dialog box and put the "it" into a field, but it got put in as a single line string (all the returns disappeared)
5. I could have .csv file imported from email or another app but that has it's own process http://lessons.livecode.com/m/4069/l/10 ... lc-ios-app

I have looked through http://lessons.livecode.com/m/4069/l/29 ... -on-mobile and http://livecode.byu.edu/mobile/device-specific.php
The difficulty is the whole Native Field process (mobileControlCreate) seems like it may be tricky to learn and get full functionality out of it as an amateur, particularly as I'll probably need the field to be editable and scrollable with multiple lines of text.
And my attempt below doesn't seem to have generated anything on my card.

Any suggestions for a workaround without creating a Native Field?
Otherwise, any feedback on the code below?

Code: Select all

local sControlID

on preOpenCard
   if the environment is "mobile" then
      mobileControlCreate "multiline", "nameinput"
      put the result into sControlID -- save it for later reference
   end if
   mobileControlSet "nameinput", "visible", true
   mobileControlSet "nameinput", "rect", "100,150,400,176"
   mobileControlSet "nameinput", "backgroundColor", "0,0,255"
   mobileControlSet "nameinput", "opaque", true
   mobileControlSet "nameinput", "fontName", "Helvetica"
   mobileControlSet "nameinput", "fontSize", 24
   mobileControlSet "nameinput", "textColor", "0,0,0"
   mobileControlSet "nameinput", "borderStyle", "none"
   mobileControlSet "nameinput", "autoCapitalizationType", "sentences"
   mobileControlSet "nameinput", "autoCorrectionType", "Yes"
   mobileControlSet "nameinput", "autoClear", "true"
   mobileControlSet "nameinput", "text", "bonjour"

end preOpenCard

on closeCard
   if the environment is "mobile" then
      mobileControlDelete "nameinput"
   end if
end closeCard

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7238
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: iOS copy paste

Post by jacque » Sun Apr 26, 2020 4:58 pm

Your research is accurate, copy and paste are only supported on native input controls. And your script looks fine on first glance.

Because this is a scripted native control you won't see anything in the IDE (and it will probably throw errors if you try.) You'll need to run the app on a mobile device or in the simulator to actually see it work.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

gstarox
Posts: 14
Joined: Sun Apr 12, 2020 3:31 am

Re: iOS copy paste

Post by gstarox » Tue Apr 28, 2020 12:30 pm

jacque wrote:
Sun Apr 26, 2020 4:58 pm
Your research is accurate, copy and paste are only supported on native input controls. And your script looks fine on first glance.

Because this is a scripted native control you won't see anything in the IDE (and it will probably throw errors if you try.) You'll need to run the app on a mobile device or in the simulator to actually see it work.
I could not see anything when I ran my app on a mobile device though :(

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7238
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: iOS copy paste

Post by jacque » Tue Apr 28, 2020 4:51 pm

Native fields are generally without borders so they aren't visible but they should be there. Try tapping on it and see if you get an insertion point. You can set a border on it if you want to see it's location.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “iOS Deployment”