How to make a text field "copyable" but not editable?

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

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

How to make a text field "copyable" but not editable?

Post by Zax » Wed May 29, 2019 10:19 am

Hello,

Is there a way to make a text field "copyable" but not editable?
I know this could easily be done with a script attached to a button "Copy" for example, but I prefer to let the user select part of the text, and then use the standard menu item "Copy"... but this field shouldn't be editable, so the user can't modify the field.

In fact, I would like a field like this text you'are reading in your browser: you have the ability to select and copy some characters, but not modify the page's texts.

Thank you.

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

Re: How to make a text field "copyable" but not editable?

Post by Klaus » Wed May 29, 2019 10:34 am

Hi Zax,

just take an ordinary field like "Scrolling field" and only check "Locktext" additionally.
Worked here as advertized: text stays select- and copy-, but not edit-able. :-)

Best

Klaus

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Re: How to make a text field "copyable" but not editable?

Post by Zax » Wed May 29, 2019 11:07 am

Danke Klaus :)

I was trying on a label field... My bad.

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

Re: How to make a text field "copyable" but not editable?

Post by Klaus » Wed May 29, 2019 11:12 am

Will also work with a "Label" field, if you check "TraversalOn" and "Autohilite" in the inspector!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: How to make a text field "copyable" but not editable?

Post by dunbarx » Wed May 29, 2019 2:47 pm

Interestingly, text in a locked field can only be selected by clicking and dragging across the desired string. Double-clicking does not work at all. This can be scripted, though:

Code: Select all

on mouseDoubleDown
   select the clickText
end mouseDoubleDown
Craig

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to make a text field "copyable" but not editable?

Post by bogs » Wed May 29, 2019 3:40 pm

dunbarx wrote:
Wed May 29, 2019 2:47 pm
...text in a locked field can only be selected by clicking and dragging across the desired string.
Say whaaaa...? :shock: (read the tool tip in that video)
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: How to make a text field "copyable" but not editable?

Post by dunbarx » Wed May 29, 2019 4:15 pm

Bogsy.

I have seen your tutorials. Lovely, all.

It was not obvious to me that one of them in particular addressed this issue. Not sure how I missed that connection. :shock:

Craig :wink:

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Re: How to make a text field "copyable" but not editable?

Post by Zax » Wed May 29, 2019 5:53 pm

Klaus wrote:
Wed May 29, 2019 11:12 am
Will also work with a "Label" field, if you check "TraversalOn" and "Autohilite" in the inspector!
You're right, Klaus. "Autohilite" for a field was not obvious.
Thanks dunbarx for the "mouseDoubleDown" tip.

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to make a text field "copyable" but not editable?

Post by bogs » Wed May 29, 2019 8:24 pm

dunbarx wrote:
Wed May 29, 2019 4:15 pm
Not sure how I missed that connection.
Happens to me all the time. See, what happens is, I get on the 5:15 for Albuquerque, when what I really needed was the 6:20 to St. Joe...
:mrgreen:
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: How to make a text field "copyable" but not editable?

Post by dunbarx » Wed May 29, 2019 9:32 pm

dunbarx wrote:
Not sure how I missed that connection.

Happens to me all the time.
Hmmm. We have a failure to communicate. Fortunately, it matters not a whit.

I meant that there was no clue that a video explaining that very thing was lingering nearby. It was not mentioned anywhere earlier in the thread.

It matters not a whit. :wink:

Craig

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to make a text field "copyable" but not editable?

Post by bogs » Wed May 29, 2019 10:51 pm

That is good, I don't have many wits left :wink:
Image

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: How to make a text field "copyable" but not editable?

Post by kaveh1000 » Thu May 30, 2019 2:39 pm

I have filed a suggestion to show the cursor even when field is locked:

https://quality.livecode.com/show_bug.cgi?id=22030
Kaveh

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: How to make a text field "copyable" but not editable?

Post by dunbarx » Thu May 30, 2019 4:32 pm

I have filed a suggestion to show the cursor even when field is locked:
I understand what you are aiming at, but this would go against typical interface guidelines, I think, if the cursor changed to the usual "iBeam" style. Perhaps a different one?

Craig

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

Re: How to make a text field "copyable" but not editable?

Post by jacque » Thu May 30, 2019 5:20 pm

I think if the cursor were visible in a locked field, we'd all start getting bug reports about how typing fails.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: How to make a text field "copyable" but not editable?

Post by dunbarx » Thu May 30, 2019 8:32 pm

I think if the cursor were visible in a locked field,
Jacque. So you mean any cursor of any kind. I get where you are coming from.

Craig

Post Reply