nsIClipboard

This interface supports basic clipboard operations such as: setting, retrieving, emptying, matching and supporting clipboard data.
继承于: nsISupports 最后修改于Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)

方法概述

void emptyClipboard(in long aWhichClipboard);
void forceDataToClipboard(in long aWhichClipboard); 已废弃 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();

常量

Most users will expect clipboard operations to use the global clipboard. In fact, the kSelectionClipboard is peculiar to the X Windows System, and not used much even under X.

常量名称 描述
kSelectionClipboard 0 Clipboard for selection.
kGlobalClipboard 1 Clipboard for global use.

方法

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 
);
参数
aWhichClipboard
Specifies the clipboard to which this operation applies.

已废弃 Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)

forceDataToClipboard()

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 
);
参数
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 
);
参数
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 
);
参数
aFlavorList
An array of ASCII strings.
aLength
The length of the aFlavorList.
aWhichClipboard
Specifies the clipboard to which this operation applies.
返回值

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 
);
参数
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();
参数

None.

返回值

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

相关链接

文档标签和贡献者

 此页面的贡献者: ziyunfei
 最后编辑者: ziyunfei,