PhClipboardRead()

Copy data from the clipboard

Synopsis:

typedef char PhClipType[8];

PhClipboardHdr *PhClipboardRead(unsigned short ig,
                                PhClipType type);

Arguments:

ig
The input group. Each input group has its own private clipboard. To determine the current input group, call PhInputGroup(), passing to it the event that triggered the clipboard operation (e.g. cbinfo->event).
type
The data type to read from the clipboard.

Library:

ph

Description:

This function copies the clipboard data in that matches type from the Photon clipboard, and returns a pointer to the data populated in a PhClipboardWrite structure.

Returns:

A pointer to a populated PhClipboardWrite
Successful completion.
NULL
An error occurred.

Examples:

This callback reads data from the clipboard, and pastes it in a PtText widget named text:

int
paste_from_clip( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )

{
    int *cursor, ig, insertion_pt;
    PhClipboardHdr *ptr;

    ig=PhInputGroup(cbinfo->event);

    PtGetResource(ABW_text, Pt_ARG_CURSOR_POSITION, &cursor, 0);
    insertion_pt=*cursor;

    if (ptr=PhClipboardRead(ig,Ph_CLIPBOARD_TYPE_TEXT))
    {
        PtTextModifyText(ABW_text, insertion_pt, insertion_pt,
            insertion_pt, ptr->data, utf8strblen( ptr->data, ptr->length, NULL ) );
        free(ptr->data);
        free(ptr);
    }

    PtContainerGiveFocus(ABW_text,NULL);
    return(Pt_CONTINUE);

}

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PhClipboardCopyString(), PhClipboardHdr, PhClipboardPasteString(), PhClipboardWrite