Special Paste

Paul Hibbert paul at livecode.org
Fri May 29 22:47:24 EDT 2020


Hi Charles,

Your examples are about pasting;

> Both Apple's Pages and Microsoft’s Word software have key commands for pasting text into an existing document to match the current formatting (font).

But, your question is about copying;

> How do you script to accomplish this when copying text to the clipboard in a button so the user does not have to use keyboard commands?

However, you can manipulate the clipBoardData both when when copying and pasting if you wish.

When copying the text, if you want the clipboard to contain unformatted (Plain) text, then use this in a “Copy Unformatted" button:

   on mouseUp
       set the clipBoardData["text"] to the selection
   end mouseUp

Or when pasting unformatted text, use this in a “Paste Unformatted” (= “Paste and Match Style or Paste and Match Formatting”) button:

   on mouseUp
       put the clipBoardData["text"] into the selection
   end mouseUp

Or if your app has a menu, then your Edit Menu script may look something like this:

on menuPick pWhich
   switch pWhich
      case "Cut"
         Cut
         break
      case "Copy"
         Copy
         break
      case "Copy Plain Text"
         set the clipBoardData["text"] to the selection
         break
      case "Paste"
         Paste
         break
      case "Paste and Match Style"
         put the clipBoardData["text"] into the selection
         break
      case "Clear"
         Clear
         break
      case "Preferences"
         go cd "Preferences"
         break
   end switch
end menuPick

By pasting Unformatted Text, the pasted text will take on the style of the text at the selection point.

clipBoardData in the Dictionary explains more.

Have fun.

Paul



> On May 28, 2020, at 07:04, Charles Szasz via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Both Apple's Pages and Microsoft’s Word software have key commands for pasting text into an existing document to match the current formatting (font). How do you script to accomplish this when copying text to the clipboard in a button so the user does not have to use keyboard commands?
> 
> Sent from my iPad
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list