Copying text in a field including the font style

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
jasper500
Posts: 5
Joined: Sun Oct 13, 2013 2:51 pm

Copying text in a field including the font style

Post by jasper500 » Sun Oct 13, 2013 3:01 pm

I am writing a character map program for mac and am having problems copying the rtf text in a field. I am using this code to copy the field contents:
set the clipboard data["rtf"] to the rtf text of field "CharsToCopy"
But when I paste it into word, the font is different. Any ideas why this isnt working?

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

Re: Copying text in a field including the font style

Post by dunbarx » Sun Oct 13, 2013 3:49 pm

Hi.

Do you have a typo in that you separate the words "clipboard" and "data"?

Anyway, try using "the htmlText" property. This preserves the text attributes.

Craig Newman

jasper500
Posts: 5
Joined: Sun Oct 13, 2013 2:51 pm

Re: Copying text in a field including the font style

Post by jasper500 » Sun Oct 13, 2013 6:26 pm

Yes Craig, sorry about that, I did use clipboarddata and rtftext as single words but it still didn't work

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

Re: Copying text in a field including the font style

Post by dunbarx » Sun Oct 13, 2013 6:34 pm

So, how about the htmlText?

Craig

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Copying text in a field including the font style

Post by Simon » Sun Oct 13, 2013 6:41 pm

OK lets roll these 2 topics into 1
Jasper500.. don't double post your questions and if you can post a stack that displays this problem :)

Hi Craig.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

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

Re: Copying text in a field including the font style

Post by jacque » Sun Oct 13, 2013 7:48 pm

If you haven't set a specific font for the field text, it will inherit the default font from the IDE. That means both the rtf and html text won't have a font specification when you copy it. When you paste it into Word, since there is no font specified, Word will use its default font.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jasper500
Posts: 5
Joined: Sun Oct 13, 2013 2:51 pm

Re: Copying text in a field including the font style

Post by jasper500 » Tue Oct 15, 2013 9:25 am

Hi Jacque, I have indeed set the font type for the field and Craig I tried to post my stack on the forum, but was not allowed to, presumably because I am new to the forum. However I am narrowing down the problem in that the code : set the clipboarddata["rtf"] to the rtftext of field "CharsToCopy" works for ASCII characters 0 to 127. Characters from 128 to 255 are different to the ones expected.
I suspect that I might have to use unicode, so will look into this further.

Post Reply