Skip to content

Commit 817c1de

Browse files
committed
Add 'RFB::clipboardreceived' event
1 parent 6cda832 commit 817c1de

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

core/rfb.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,11 +2335,13 @@ export default class RFB extends EventTargetMixin {
23352335

23362336
_writeClipboard(text) {
23372337
if (this._viewOnly) return;
2338-
if (this._asyncClipboard.writeClipboard(text)) return;
2339-
// Fallback clipboard
2340-
this.dispatchEvent(
2341-
new CustomEvent("clipboard", {detail: {text: text}})
2342-
);
2338+
if (!(this._asyncClipboard.writeClipboard(text))) {
2339+
// Fallback clipboard
2340+
this.dispatchEvent(
2341+
new CustomEvent("clipboard", {detail: {text: text}})
2342+
);
2343+
}
2344+
this.dispatchEvent(new CustomEvent("clipboardreceived"));
23432345
}
23442346

23452347
_handleServerCutText() {

docs/API.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ protocol stream.
9696
- The `clipboard` event is fired when clipboard data is received from
9797
the server.
9898

99+
['clipboardreceived'](#clipboardreceived)
100+
- The `clipboardreceived` event is fired after the `clipboard` event
101+
or after the clipboard has been updated through the
102+
[Clipboard module](API-internal.md#11-module-list). The copied text
103+
has already been written to the system clipboard or the clipboard panel.
104+
99105
[`clippingviewport`](#clippingviewport)
100106
- The `clippingviewport` event is fired when `RFB.clippingViewport` is
101107
updated.

0 commit comments

Comments
 (0)