nsIClipboard 编辑

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.

ConstantValueDescription
kSelectionClipboard0Clipboard for selection.
kGlobalClipboard1Clipboard for global use.
kFindClipboard2Clipboard 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:80 次

字数:8189

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文