Copying text text (and its format) to another field

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
rumplestiltskin
Posts: 223
Joined: Wed Jun 21, 2006 7:33 pm
Contact:

Copying text text (and its format) to another field

Post by rumplestiltskin » Sun Dec 01, 2013 9:51 pm

The title pretty much says it all. I have a field "theSource" and a field "theDestination". Field "theSource" contains some text that the user may have formatted in a particular manner (size, font, etc.). I'd like to have a bit of code in a button that copies not only the text but the style to field "theDestination". I imagine the "styledText" property has something to do with this but it appears fairly complicated as it seems to require some sort of array.

What I have been using is

Code: Select all

copy field "theSource" to field "theDestination"
..but this, of course, seems only to copy the unformatted text to field "theDestination"

As always, suggestions gratefully accepted.

Barry

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

Re: Copying text text (and its format) to another field

Post by Klaus » Sun Dec 01, 2013 10:03 pm

Hi Barry,

use htmltext to preserve formatting:
...
set the htmltext of fld "theDestination" to the htmltext of fld "theSource"
## using "the rtftext of ..." should work, too!
...


Best

Klaus

rumplestiltskin
Posts: 223
Joined: Wed Jun 21, 2006 7:33 pm
Contact:

Re: Copying text text (and its format) to another field

Post by rumplestiltskin » Sun Dec 01, 2013 11:08 pm

Klaus,

Yep; using the rtfText worked perfectly. As always, many thanks for the lesson!

Barry

Post Reply