This fork of Clippy allows retrieving text dynamically via JavaScript using ExternalInterface, instead of setting the text at embed-time.
Switch branches/tags
Nothing to show
Pull request Compare This branch is 3 commits ahead of mojombo:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Clippy - Helping you copy text to your clipboard

Clippy is a very simple Flash widget that makes it possible to place arbitrary text onto the client's clipboard. Here is what Clippy looks like on GitHub:

Clippy in action

This is a fork of the original Clippy by Tom Preston-Werner. It modifies Clippy to copy text by calling a JavaScript callback instead of passing the text to copy as a flashvar. This allows for increased flexibility in retrieving the data data to copy, and eliminates duplication of text (a possible concern if the text to be clipped is lengthy).

Here is a sample Rails (Ruby) helper that can be used to place Clippy on a page:

def clippy(callback, parameter = nil, options = {})
  bgcolor   = options[:bgcolor] || '#fff'
  id        = options[:id] || 'clippy'
  css_class = options[:class] || 'clippy'
  html = <<-HTML
    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-44455354000"
            id="#{id}" class="#{css_class}">
    <param name="movie" value="/flash/clippy.swf" />
    <param name="allowScriptAccess" value="always" />
    <param name="quality" value="high" />
    <param name="scale" value="noscale" />
    <param NAME="FlashVars"
           value="callBack=#{callback}&parameter=#{parameter}" />
    <param name="bgcolor" value="#{bgcolor}" />
    <embed src="/flash/clippy.swf"

Clippy (this fork, at least) accepts two parameters (as flashvars):

  • callBack (required) - A string representing a valid javascript function, such as function_name or MyApplication.function_name. Yes, "callBack" is a stupid capitalization, but "callback" is a keyword in Haxe.
  • parameter (optional) - A parameter to pass to aforementioned function

It will then call the function provided, and copy its return value to the clipboard.

For example, to copy the HTML content of a div with a specific ID in Rails, using jQuery and the helper above:

<div id="my_awesome_content">
  This content is so <i>awesome</i>!
<script type="text/javascript">
  function fetch_content(id) {
    return $('#' + id).html();

<%= clippy 'fetch_content', 'my_awesome_content' %>

Installation (Pre-Built SWF)

If you want to use Clippy unmodified, just copy build/clippy.swf to your public directory or wherever your static assets can be found.

Installation (Compiling)

In order to compile Clippy from source, you need to install the following:

The haXe code is in clippy.hx, the button images are in assets, and the compiler config is in compile.hxml. Make sure you look at all of these to see where and what you'll need to modify. To compile everything into a final SWF, run the following from Clippy's root directory:

swfmill simple library.xml library.swf && haxe compile.hxml

If that is successful, copy build/clippy.swf to your public directory or wherever your static assets can be found.


If you'd like to hack on Clippy, start by forking my repo on GitHub:

The best way to get your changes merged back into core is as follows:

  1. Clone down your fork
  2. Create a topic branch to contain your change
  3. Hack away
  4. If you are adding new functionality, document it in
  5. If necessary, rebase your commits into logical chunks, without errors
  6. Push the branch up to GitHub
  7. Send me (mojombo) a pull request for your branch


MIT License (see LICENSE file)