Setting textSize in the clipboardData

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
deeverd
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 165
Joined: Mon Jul 16, 2007 11:58 pm
Location: Las Vegas, NV

Setting textSize in the clipboardData

Post by deeverd » Sun Dec 10, 2017 8:54 pm

Hello Forum,

After some hours, going through the forum and the big new dictionary, I still can't seem to copy text to the clipboard and retain the correct textSize.

When I use the code...

Code: Select all

set the clipboardData["RTF"] to the RTFText of field "copyThisField"
The textFont of "Times New Roman" comes through but the text that is pasted from my clipboard does not retain the correct textSize.

Is there a simple trick to accomplishing this feat? There usually is in LiveCode, but even after searching, I'm just not sure what it is.

Or is there a way of resetting the textSize on the clipboardData after copying a field?

Thanks in advance for whatever advice you can give.
Cheers

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9578
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Setting textSize in the clipboardData

Post by dunbarx » Sun Dec 10, 2017 10:00 pm

I think you are looking for the "HTMLText"

Craig Newman

deeverd
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 165
Joined: Mon Jul 16, 2007 11:58 pm
Location: Las Vegas, NV

Re: Setting textSize in the clipboardData

Post by deeverd » Sun Dec 10, 2017 10:55 pm

Hi Craig,

Nope. Thanks for trying though.

Originally, I did just that. I used HTMLText rather than RTFText.

But when I used HTMLText, not only did I not get the correct textSize, I didn't even get the correct textFont. What it gave me instead was Segoe UI 9.

When I used RTFText, I at least got the textFont, but still not the textSize.

So, there's a reason I didn't use HTMLText, though I also don't understand why that didn't work.

Best,
deeverd

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Setting textSize in the clipboardData

Post by jmburnod » Sun Dec 10, 2017 11:38 pm

Hi deeverd,
What version of LiveCode do you use ?
I tested your script with two textfonts, two textsizes and two colors
and it works here (LC indy 8.1.6)

Best regards
Jean-Marc
https://alternatic.ch

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9578
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Setting textSize in the clipboardData

Post by dunbarx » Mon Dec 11, 2017 2:09 am

I guess I am not understanding. If I have two fields, and in the first one I place some text of all sort of silly font styles, sizes and colors, and then in a button:

Code: Select all

on mouseUp
   set the clipboardData to the htmlText of fld 1
   set the htmlText of fld 2 to the clipBoardData
end mouseUp
I get all sorts of silly font styles, sizes and colors in fld 2.

You surely mean something different.

Craig

deeverd
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 165
Joined: Mon Jul 16, 2007 11:58 pm
Location: Las Vegas, NV

Re: Setting textSize in the clipboardData

Post by deeverd » Mon Dec 11, 2017 3:16 am

Hi Jean-Marc,

I'm using LiveCode version 8.1.3.

Just saw that 8.1.8 is a stable version, so I'll upgrade and see if that makes any difference, then report back.

Apologies for the delay in responding. I live in a small town of just 200-300 permanent residents and was away helping a neighbor move some heavy equipment.

deeverd
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 165
Joined: Mon Jul 16, 2007 11:58 pm
Location: Las Vegas, NV

Re: Setting textSize in the clipboardData

Post by deeverd » Mon Dec 11, 2017 3:26 am

Hi Craig,

Just saw your message. The example code in your post works fine, and is similar to what I do when I want to protect the formatting in a text field when I use some "replace" code in it. But...

In my case, however, I'm not moving code from one field to another in a LiveCode program. The problem occurs when I put text (from a LiveCode field) with its formatting intact on the clipboard and then try pasting it into a MS Word document. In the HTMLText command I lose both the font style and the font size; while in the RTFText command I lose only the font size (it seems to automatically default to either 9 point or 10.5 point).

Hope that clears up some of the confusion.

I just sent a message to Jean-Marc and will upgrade my LiveCode Windows version 8.1.3 to 8.1.8 and see if that solves the problem.

Cheers

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Setting textSize in the clipboardData

Post by jmburnod » Mon Dec 11, 2017 10:53 am

Hi deewerd,
The problem occurs when I put text (from a LiveCode field) with its formatting intact on the clipboard and then try pasting it into a MS Word document
OK. same result for me when i paste into a LibreOffice document
Best
Jean-Marc
https://alternatic.ch

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

Re: Setting textSize in the clipboardData

Post by bogs » Mon Dec 11, 2017 5:23 pm

deeverd wrote:
Sun Dec 10, 2017 8:54 pm
...copy text to the clipboard and retain the correct textSize.
When I use the code...

Code: Select all

set the clipboardData["RTF"] to the RTFText of field "copyThisField"
. The textFont of "Times New Roman" comes through but the text that is pasted from my clipboard does not retain the correct textSize.
.
I used 8.1.3 in wine, so this is hardly conclusive, but should be fairly accurate as to what is in the clipboard.
. the first line you see in wordpad is the direct copy of the field
. the second line is the htmlText version of what was on the clipboard
. the third line on to the end is the data on the clipboard from the rtfText
Image
It looks to me like all the information is copied to the clipboard? Maybe something is going on with the way wordpad interprets it when it is pasted?
Last edited by bogs on Mon Dec 11, 2017 5:51 pm, edited 1 time in total.
Image

deeverd
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 165
Joined: Mon Jul 16, 2007 11:58 pm
Location: Las Vegas, NV

Re: Setting textSize in the clipboardData

Post by deeverd » Mon Dec 11, 2017 5:30 pm

Hello Jean-Marc and Others on the Forum,

This morning, I installed LiveCode 8.1.8, as promised, and gave it a try again.

I have the same results but also came up with a simple work around.

To quickly reiterate, when using HTMLText, which I put on a clipboard from a LiveCode field (using "set clipboardData" command) and paste it into a MS Word document, I lose both the textFont and textSize, which comes out instead as Segoe UI 9 when it is supposed to be Times New Roman 12.

When using RTFText, I get Times New Roman, but the textSize gets reduced down to 9 upon pasting.

A simple workaround is simply to temporarily set the textSize of my field at 16.5, then when I cut and paste it into a MS Word document, it comes out as 12 point font.

There seems to be a proportional drop in size of the fontSize, but 16.5 drops down to 12.

Here's some sample code for what I do now:

Code: Select all


	lock screen
   
	set the textSize of field "copyThisField" to 16.5

	set the clipboardData["RTF"] to the RTFText of field "copyThisField"
   
	set the textSize of field "copyThisField" to 12
   
	unlock screen
	
Hope that helps.
Cheers,
deeverd

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Setting textSize in the clipboardData

Post by [-hh] » Tue Dec 12, 2017 4:47 pm

With LC 8 use the fullClipboardData["RTF"]:

Code: Select all

on mouseUp
  lock the clipboard
  set the fullClipboardData to empty
  set the fullClipboardData["RTF"] to the rtfText of fld 1
  unlock the clipboard
end mouseUp
Then paste into TextEdit, Pages, OpenOffice, Word or whatever.
shiftLock happens

deeverd
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 165
Joined: Mon Jul 16, 2007 11:58 pm
Location: Las Vegas, NV

Re: Setting textSize in the clipboardData

Post by deeverd » Tue Dec 12, 2017 5:44 pm

Awesome!

fullClipboardData["RTF"] does work.

Problem solved and now there is no need for a work-around solution.

Out of curiosity, I did try the fullClipboardData command with HTML instead of RTF. The HTML will capture the textFont but it still makes the textSize smaller. RTF is definitely the better choice.

Thanks,
deeverd

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”