Electron, v3

Writing to Clipboard Exercise

Steve Kinney

Steve Kinney

Temporal
Electron, v3

Check out a free preview of the full Electron, v3 course

The "Writing to Clipboard Exercise" Lesson is part of the full, Electron, v3 course featured in this preview video. Here's what you'd learn in this lesson:

Students are instructed to implement the ability to write data to the system clipboard from the Clipmaster application.

Preview
Close

Transcript from the "Writing to Clipboard Exercise" Lesson

[00:00:00]
>> What's really cool is like think about combining the two apps that we did previously. Let's say you had a file and you wanted to do something where it's like reading from a file maybe parsing it and adding certain things in at various like dominoes. There's a whole bunch of ways that you can like any given one of these things kinda cool, right?

[00:00:17]
I think what is cooler is okay, what are the if I could read from the file system, if I could pull system information, if I had logs that are writing to standard out, right? Could I grab that stream in node and then build a UI on top of that, that allowed me to search and manipulate those logs, right?

[00:00:37]
The interesting part always is not any given one of the very tractable, reasonable things that your approach but it's the like, okay, what is the bespoke use case where some app doesn't exist at my job or in my hobby, right? Like the other day we were doing one with Arduinos and Johnny-Five, like one could theoretically build a Johnny-Five ui, right?

[00:00:55]
And turn the LEDs on and off from here and control the board directly. All of those things become possible. So my challenge to you is if we go into the code here. In application.tsx clipping has an on remove, but it also has an on copy, which is what like I'll give you a hint when that gets triggered.

[00:01:18]
It's when somebody clicks that button, right? Could we take that, we already are wired up some of the writing to the clipboard. Could we just like, again, complete the loop and get that piece in place? And then we've got kind of like, we can kinda then do some other cool things with this app that involve like the OSS integration, but let's like, at least we can copy from the clipboard.

[00:01:37]
This app kinda stinks if we can't do the opposite, awesome Cool, cool, cool. So I guess the other part is writing to the clipboard, where ideally we should be able to just do on copy. Let's look at the actual implementation here, as I remember. So button on click we, yeah, whatever the copy is, we passed the value in, which should work for my writing to the clipboard, right.

[00:02:16]
Cool. So we will go ahead and try that out we'll say, on copy we'll do window.api.writetoclipboard. And now, if the world likes me, I shouldn't even need to change anything. Is a hotdog a really a form of taco? Now, I should be able to copy this clipboard. Yes, I can now save important things that I need to reuse over and over again.

[00:02:52]
2020 hindsight. You know what this app would be really good for, saving dank memes. All right, that you need available to copy to the clipboard at a moment's notice. I think that's maybe what I should have done with this. And then you maybe save it to the file system so then you know exactly where to get them, and you can see it as well.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now