Native mobile field which allows highlighting and copying but not editing

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bamakojeff
Posts: 13
Joined: Tue Dec 06, 2022 6:53 pm

Native mobile field which allows highlighting and copying but not editing

Post by bamakojeff » Sun Mar 17, 2024 8:04 pm

I am trying to create a native mobile field which allows the user to highlight text and then copy it, but not edit (i.e. change) the text. This is done in a Livecode field by enabled both "lockText" and "autoHilite". But I cannot find any sort of equivalent for a Native mobile multiline control.

I have text in a Livecode field which the user may wish to copy. Unfortunately Livecode fields cannot copy to the mobile clipboard. So I place the text from the Livecode field into a native mobile field, and now the user can highlight and copy. But (at least on Android; have not tested on iOS) they can also edit the text, which I would prefer not be possible. They should not be able to change the text, just highlight a section and copy it.

I tried setting "editable" to false:

Code: Select all

mobileControlset "myNativeField", "editable", false 
That does lock the text so it cannot be edited. But unfortunately it does not allow the user to highlight and copy text, merely read it.

This must be possible since many mobile apps do just this. I can highlight text in my web browser and copy it but not edit it. Indeed, the mobile keyboard does not ever appear when I highlight text in the web browser. It always appears when I create a native mobile field and click to enter it.

Anyone know of a way to accomplish this? Or perhaps some other clever way to accomplish my ultimate goal of allowing mobile users to highlight and copy a section of text from a Livecode field.

TIA.

Jeff

bamakojeff
Posts: 13
Joined: Tue Dec 06, 2022 6:53 pm

Re: Native mobile field which allows highlighting and copying but not editing

Post by bamakojeff » Wed Mar 20, 2024 6:45 pm

I've not had any luck with this. But another way this could be accomplished without making changes to the field would be to hide the keyboard even while the field retains focus.

So does any one know of a way to hide the mobile keyboard even when the field has focus? I'm hoping for something like

Code: Select all

mobileSetKeyboardType "none"
or

Code: Select all

mobileControlset "myNativeField", "readonly", true
Ah, if only declaring a property made it exist! :-)

Jeff

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9842
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Native mobile field which allows highlighting and copying but not editing

Post by FourthWorld » Wed Mar 20, 2024 7:06 pm

This (and many other things) would be easily accomplished with a LC field, if LC's mobile engine had Clipboard support.

This request has been outstanding for some time:
https://quality.livecode.com/show_bug.cgi?id=19990

I'm unaware of a method to use the OS-native editable fields as non-editable.

If this is critical for your app, would the app work as a web app? There are many tools for crafting web apps, LC's and many others.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bamakojeff
Posts: 13
Joined: Tue Dec 06, 2022 6:53 pm

Re: Native mobile field which allows highlighting and copying but not editing

Post by bamakojeff » Wed Mar 20, 2024 10:18 pm

<SIGH>Thanks Richard. No, it's not critical. It just makes everything work the way anyone who uses mobile apps expects things to work. If you highlight something in your browser or your email to copy it, you don't expect a keyboard to pop up which allows you to change the text. But that's what happens now.</SIGH>

The documentation for the "copy" command says that it works on mobile. It even warns you that copying objects does not work on mobile. But as far as I can tell, running "copy" on an LC field does nothing on mobile. It doesn't put it on the clipboard in any case I've discovered.

This seems simple. It's one line in java on android to keep the keyboard from appearing when an editable field is clicked on.

Code: Select all

editText.setShowSoftInputOnFocus(false);

But clearly I don't understand the complexities involved to mimic this in LC. Maybe I should put my money where my mouth is, download the last LC Community edition source code, and take a look. I'll probably have a lot more compassion for how hard this is if I try to write it myself. :shock:

Thanks for the bug reference.

Jeff

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”