New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Clipboard change event to clipboard API #2280
Comments
Need that too |
👍 |
👍 would be useful for me too |
👍 |
1 similar comment
+1 |
+1 |
This isn't possible on OS X, you have to poll. It works on Windows, and miiiight work on Linux? |
@paulcbetts what do you mean by isn't possible? Did you take a look into how Qt implements this functionality? |
@zcbenz any plans in roadmap to implement this? |
@destan As far as I can see from https://github.com/qtproject/qtbase/blob/dev/src/plugins/platforms/cocoa/qmacclipboard.mm, it doesn't implement it at all, the event just doesn't fire. |
@paulcbetts I don't know about mac but it works on windows and linux (currently I am using it). Moreover you may be misinterpreting the source code because if it wasn't available on mac it would have been stated here http://doc.qt.io/qt-5/qclipboard.html#changed |
+1, I could use this |
Chromium is going to add this feature, we will be able to use it Electron after it gets finished: |
I'm not so sure, it looks like only X11 and ChromeOS get it |
want it badly! thx. |
@zcbenz https://bugs.chromium.org/p/chromium/issues/detail?id=460610 seems fixed, do you have time to check it out? |
@zcbenz any updates? |
+1 |
@destan Still only implemented for X11 and ChromeOS |
+1 for this request |
End: Make the workflow more natural. Means: Remove the Ctrl/Cmd+Shift+C shortcut. Electron's clipboard API doesn't expose a change event or observable event stream (see electron/electron#2280). Until it does, we're forced to busy wait, checking the contents of the clipboard every N ms. Fortunately, electron-clipboard-watcher already implements this. However, it's API isn't ideal. It's as important to start a conversation with that module's author, @joshwnj, as it is to meet the stated end. With the above in mind, add the observable-clipboard module, which uses the wraps the electron-clipboard-watcher with zen-observable, an implementation of the Observable spec (see https://tc39.github.io/proposal-observable/).
Blocking issue https://bugs.chromium.org/p/chromium/issues/detail?id=460610#c22 has been fixed, but in chromium stable 56, I think that is why this issue hasn't been fixed yet, as But now it's upgraded to 56 via PR electron/libchromiumcontent#258. This issue might be able to be fixed this time. ping @zcbenz |
@twang2218 this is still only implemented on Linux in Chromium. https://cs.chromium.org/search/?q=NotifyClipboardDataChanged&type=cs |
I'm also wishing Electron had clipboard events. 👍 |
Oh, that's unfortunately. For my case, I got performance hit of keep checking for new clipboard on Linux, which is 10-20 times slower than macOS. It would be great even if only implemented this feature on Linux. |
For now I've simply used some preload code in a frameless hidden window as a kind of clipboard manager utility. I'm using an interval timer of 250ms to read the clipboard and compare it to the last value; if it has changed I send an IPC message to the main Node Electron process, which decides if it's relevant and if it is then sends an IPC message to the visible UI window to update the display. It suits my needs and is very responsive, as soon as I copy text in another application it immediately appears in my Electron app. I don't have access to a Mac so I've only tested this on linux. |
@LewdEwe-ErikWallace Do you have that code somewhere? |
Correct me if I'm wrong, but it should be possible to write a native node add-on to support this. Native add-ons are written in C/C++ and compiled by node-gyp; The add-on would subscribe to the system's native clipboard events & call stored callback JS functions when en event rises. |
Sorry I didn't see your comment sooner. Here is an example extracted from my project: https://gist.github.com/LewdEwe-ErikWallace/d6e36f899a77a4f05e46388c254d014f |
This would also be very useful to an electron application I am working on. |
@dsantratlock |
As this is still only implemented in Chromium for Linux, I also believe this is better as a native addon rather then implemented in such a platform-specific capacity. As such, i'm labeling this a |
Hey folks, any updates? |
Hey folks, check my npm module (node-clipboard-event) out. |
I need this tooo |
Hey bro, your module is awesome, is there any way to get the data/text which has been changed?
|
https://github.com/electron/electron/blob/main/docs/api/clipboard.md#clipboard |
For anyone interested in this feature, I suggest you star this crbug: https://bugs.chromium.org/p/chromium/issues/detail?id=933608 |
starred.
|
I'd like to write a clipboard manager that monitors the systems' clipboard. Searching for an event in the clipboard I didn't found one.
I know there exists the HTML5 clipboard API, but my application needs to monitor the clipboard when it does not have focus.
I mean like
QClipboard
'svoid selectionChanged()
andvoid dataChanged()
or like GTK'sowner-changed
.Currently I'm retrieving the contents of the clipboard and look manually whether the content has changed every 20ms, which should not be the preferred way. It works but I really shouldn't resort to a busy polling loop...
The text was updated successfully, but these errors were encountered: