FLTK 1.3.2
Selection & Clipboard functions

FLTK global copy/cut/paste functions declared in <FL/Fl.H> More...

Functions

static void Fl::add_clipboard_notify (Fl_Clipboard_Notify_Handler h, void *data=0)
 FLTK will call the registered callback whenever there is a change to the selection buffer or the clipboard. More...
 
static void Fl::copy (const char *stuff, int len, int destination=0)
 Copies the data pointed to by stuff to the selection buffer (destination is 0) or the clipboard (destination is 1); len is the number of relevant bytes in stuff. More...
 
static int Fl::dnd ()
 Initiate a Drag And Drop operation. More...
 
static void Fl::paste (Fl_Widget &receiver, int source)
 Pastes the data from the selection buffer (source is 0) or the clipboard (source is 1) into receiver. More...
 
static void Fl::paste (Fl_Widget &receiver)
 Backward compatibility only. More...
 
static void Fl::remove_clipboard_notify (Fl_Clipboard_Notify_Handler h)
 Stop calling the specified callback when there are changes to the selection buffer or the clipboard.
 
static void Fl::selection (Fl_Widget &owner, const char *, int len)
 Changes the current selection. More...
 
static Fl_WidgetFl::selection_owner ()
 back-compatibility only: Gets the widget owning the current selection More...
 
static void Fl::selection_owner (Fl_Widget *)
 Back-compatibility only: The single-argument call can be used to move the selection to another widget or to set the owner to NULL, without changing the actual text of the selection. More...
 

Detailed Description

FLTK global copy/cut/paste functions declared in <FL/Fl.H>

Function Documentation

void Fl::add_clipboard_notify ( Fl_Clipboard_Notify_Handler  h,
void *  data = 0 
)
static

FLTK will call the registered callback whenever there is a change to the selection buffer or the clipboard.

The source argument indicates which of the two has changed. Only changes by other applications are reported.

Note
Some systems require polling to monitor the clipboard and may therefore have some delay in detecting changes.
static void Fl::copy ( const char *  stuff,
int  len,
int  destination = 0 
)
static

Copies the data pointed to by stuff to the selection buffer (destination is 0) or the clipboard (destination is 1); len is the number of relevant bytes in stuff.

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.

int Fl::dnd ( )
static

Initiate a Drag And Drop operation.

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

Create a selection first using: Fl::copy(const char *stuff, int len, 0)

static void Fl::paste ( Fl_Widget receiver,
int  source 
)
static

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

Set things up so the receiver widget will be called with an FL_PASTE event some time in the future with the data from the specified source in Fl::event_text() and the number of characters in Fl::event_length(). 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 FLTK.

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.

void Fl::paste ( Fl_Widget receiver)
static

Backward compatibility only.

This calls Fl::paste(receiver, 0);

See also
Fl::paste(Fl_Widget &receiver, int clipboard)
void Fl::selection ( Fl_Widget owner,
const char *  text,
int  len 
)
static

Changes the current selection.

The block of text is copied to an internal buffer by FLTK (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.

static Fl_Widget* Fl::selection_owner ( )
inlinestatic

back-compatibility only: Gets the widget owning the current selection

See also
Fl_Widget* selection_owner(Fl_Widget*)
void Fl::selection_owner ( Fl_Widget owner)
static

Back-compatibility only: The single-argument call can be used to move the selection to another widget or to set the owner to NULL, without changing the actual text of the selection.

FL_SELECTIONCLEAR is sent to the previous selection owner, if any.

Copying the buffer every time the selection is changed is obviously wasteful, especially for large selections. An interface will probably be added in a future version to allow the selection to be made by a callback function. The current interface will be emulated on top of this.