Sanko Robinson

NAME

Fl::Clipboard - Global Copy/Cut/Paste Functions

Synopsis

    use Fl qw[:clipboard];

Description

This file contains functions related to text copying, cutting, and pasting. All functions can be imported with the :clipboard import tag.

Methods

Here we go...

clipboard_contains(...)

    my $text = Fl::clipboard_contains(Fl::clipboard_plain_text);

Returns non 0 if the clipboard contains data matching type. Supported types are text/plain and image.

copy(...)

    Fl::copy('words');
    Fl::copy($raw, 1);
    Fl::copy($stuff, $destination);

Copies the data pointed in $stuff to the selection buffer ($destination == 0) or the clipboard ($destination == 1).

The selection buffer is used for middle-mouse pastes and for drag-and-drop selections. The clipboard is used for traditional copy/cut/paste operations.

dnd( )

    Fl::dnd( );

Initiate a Drag And Drop operation.

The selection buffer should be filled with relevant data before calling this method. Fl will then initiate the system wide drag and drop handling. Dropped data will be marked as text.

Create a selection first using Fl::copy(...).

paste(...)

    Fl::paste( $widget, $source );
    Fl::paste( $widget, $source, $type );

Pastes the data from the selection buffer ($source == 0) or the clipboard ($source is 1) into receiver.

If $source == 1, the optional $type argument indicates what type of data is requested from the clipboard. At present, text/plain (requesting text data) and image (requesting image data) are possible. Set things up so the handle function of the receiver widget will be called with an FL_PASTE event some time in the future if the clipboard does contain data of the requested type. During processing of this event, and if type is text/plain, the text data from the specified source are in Fl::event_text() with UTF-8 encoding, and the number of characters in Fl::event_length(). If type is image,Fl::event_clipboard() returns an Fl::Image object. The receiver should be prepared to be called directly by this, or for it to happen later, or possibly not at all. This allows the window system to take as long as necessary to retrieve the paste buffer (or even to screw up completely) without complex and error-prone synchronization code in Fl.

The selection buffer is used for middle-mouse pastes and for drag-and-drop selections. The clipboard is used for traditional copy/cut/paste operations.

Platform details for image data:

Unix/Linux platform: Image data in PNG or BMP formats are recognized. Requires linking with the fltk_images library.
MSWindows platform: Both bitmap and vectorial (Enhanced metafile) data from clipboard can be pasted as image data.
Mac OS X platform: Both bitmap (TIFF) and vectorial (PDF) data from clipboard can be pasted as image data.

selection(...)

    Fl::selection( $widget, $text );

Changes the current selection.

The block of text is copied to an internal buffer by Fl (be careful if doing this in response to an FL_PASTE as this may be the same buffer returned by event_text()). The selection_owner() widget is set to the passed owner.

LICENSE

Copyright (C) Sanko Robinson.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Sanko Robinson <sanko@cpan.org>