This, that and the other (may contain nuts)

Cross Platform Copy to Clipboard

Steve Castledine  1 June 2006 08:00:00
Copying text to the clipboard should be easy enough but I remember when I looked into it last year it was not as easy as you would think.

You can of course use win32 calls etc - but we live in a multi platform world (a lot of my clients use Macs). So I put together a way of copying any text you want to the clipboard which worked on any notes client - no matter the platform.

Now it maybe that I didn't see the woods for the trees at the time - if so tell me it is easier - and the world will be happier. Otherwise this is what I did:

I created a new Form - I called mine "copyurl". I added a field - I called mine "PermLink".

Now you can either set the default value of this field to be the name of a field you want to inherit from (the underlying document if you do this from within a document) or you can use some script to set the value to whatever you choose.

Then add a new button where you wish to copy some text to the clipboard and add the following lotuscript:


      Dim workspace As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
     
      Set uidoc=workspace.ComposeDocument( "","", "copyurl" )
     
      Call uidoc.SelectAll
      Call uidoc.copy
      Call uidoc.Close(True)


Thats it - to see it in action within the dominoblog template when you add new content there is a feature in the "Action" menu to "Copy URL to clipboard".

My recent notes "tips" postings have been very simple. Over the next few weeks I hope to step up a gear and start doing some more advanced stuff (they just take longer to write!).

Image:Cross Platform Copy to Clipboard