widget/nsIClipboard.idlScriptable
This interface supports basic clipboard operations such as: setting, retrieving, emptying, matching and supporting clipboard data.
Inherits from: nsISupports Last changed in Gecko 30.0 (Firefox 30.0 / Thunderbird 30.0 / SeaMonkey 2.27)

Method overview

void emptyClipboard(in long aWhichClipboard);
void forceDataToClipboard(in long aWhichClipboard); Obsolete since Gecko 1.8
void getData(in nsITransferable aTransferable, in long aWhichClipboard);
boolean hasDataMatchingFlavors([array, size_is(aLength)] in string aFlavorList, in unsigned long aLength, in long aWhichClipboard);
void setData(in nsITransferable aTransferable, in nsIClipboardOwner anOwner, in long aWhichClipboard);
boolean supportsSelectionClipboard();
boolean supportsFindClipboard();

Constants

Most clipboard operations in Firefox use kGlobalClipboard, which is the one also used by the typical control-C/control-V keyboard shortcuts.

The kSelectionClipboard is peculiar to the X Windows System, where it refers to the PRIMARY selection, which is the one that simple mouse selection and middle-click paste operations are using.

Constant Value Description
kSelectionClipboard 0 Clipboard for selection.
kGlobalClipboard 1 Clipboard for global use.
kFindClipboard 2 Clipboard for find strings.

Methods

emptyClipboard()

This method empties the clipboard and notifies the clipboard owner. It empties the "logical" clipboard. It does not clear the native clipboard.

void emptyClipboard(
  in long aWhichClipboard
);
Parameters
aWhichClipboard
Specifies the clipboard to which this operation applies.

forceDataToClipboard()

Obsolete since Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)

Some platforms support deferred notification for putting data on the clipboard This method forces the data onto the clipboard in its various formats This may be used if the application going away.

void forceDataToClipboard(
  in long aWhichClipboard
);
Parameters
aWhichClipboard
Specifies the clipboard to which this operation applies.

getData()

This method retrieves data from the clipboard into a transferable.

void getData(
  in nsITransferable aTransferable,
  in long aWhichClipboard
);
Parameters
aTransferable
The transferable to receive data from the clipboard.
aWhichClipboard
Specifies the clipboard to which this operation applies.

hasDataMatchingFlavors()

This method provides a way to give correct UI feedback about, for instance, whether a paste should be allowed. It does not actually retrieve the data and should be a very inexpensive call. All it does is check if there is data on the clipboard matching any of the flavors in the given list.

boolean hasDataMatchingFlavors(
  [array, size_is(aLength)] in string aFlavorList,
  in unsigned long aLength,
  in long aWhichClipboard
);
Parameters
aFlavorList
An array of ASCII strings.
aLength
The length of the aFlavorList.
aWhichClipboard
Specifies the clipboard to which this operation applies.
Return value

Returns true, if data is present and it matches the specified flavor. Otherwise it returns false.

setData()

This method sets the data from a transferable on the native clipboard.

void setData(
  in nsITransferable aTransferable,
  in nsIClipboardOwner anOwner,
  in long aWhichClipboard
);
Parameters
aTransferable
The transferable containing the data to put on the clipboard.
anOwner
The owner of the transferable.
aWhichClipboard
Specifies the clipboard to which this operation applies.

supportsSelectionClipboard()

This method allows clients to determine if the implementation supports the concept of a separate clipboard for selection.

boolean supportsSelectionClipboard();
Parameters

None.

Return value

Returns true if kSelectionClipboard is available. Otherwise it returns false.

supportsFindClipboard()

This method allows clients to determine if the implementation supports the concept of a separate clipboard for find search strings.

boolean supportsFindClipboard();
Parameters

None.

Return value

Returns true if the separate clipboard for find search strings is supported. Otherwise it returns false.

See also