Lesson Details

Author: Trevor DeVore
Last Updated: 08 Feb 22:11

Tags

Revolution
0 comments for this lesson

Getting Expected Results When Setting clipboardData["html"]

When setting clipboardData["html"] the textFont of the templateField is used (or the home stack if the textFont is empty). This has implications for OS X applications where Lucida Grande is normally the default font. Lucida Grande does not have an italics style so italics will be lost when pasting into 3rd party applications. The workaround is to assign the templateField a textFont before assigning clipboardData["html"].

Copy Styled Text to the Clipboard

Copy_styled_text_to_the_clipboard_display

Executing this code in the message box places the word "Hi" on the clipboard. "Hi" should be italicized.

Paste Into 3rd Party Application

Paste_into_3rd_party_application_1_display

Now paste the string into a 3rd party application. Since this code was run on OS X the textFont of the home stack is set to Lucida Grande. Lucida Grande does not have an italic style so "Hi" (1) appears in the regular typeface (2).

Set the textFont of the templateField

Set_the_textfont_of_the_templatefield_display

Now set the textFont of the templateField to a font that has an italic style. In this example I'm using Helvetica. Note that as of Revolution 2.9 dp-3 the font used is determined when the clipboard contents are pasted into a 3rd party application. So if you change the textFont of the templateField before the string is pasted into another application "Helvetica" will not be used. The current textFont will be used.

Paste Into 3rd Party Application

Paste_into_3rd_party_application_display

Notice that after pasting the clipboard contents into TextEdit (1) the text uses the Helvetica font (2).

Comments (0)

Add your comment

Are you human?