This course is out of date and does not reflect our standards or industry best practices.

Check out a free preview of the full Electron Fundamentals, v2 course:
The "Custom Menu Item Solution" Lesson is part of the full, Electron Fundamentals, v2 course featured in this preview video. Here's what you'd learn in this lesson:

Steve live codes the solution to the exercise, then reviews the application that was built thus far.

Get Unlimited Access Now

Transcript from the "Custom Menu Item Solution" Lesson

[00:00:00]
>> Steve Kinney: We need to create a new menu item called savehtml. That is going to send a message to the renderer process. The renderer process is gonna receive that message, find all the stuff it needs, communicate back to the main process that, hey, save this html, in the same way it's doing with the button right now.

[00:00:16] So, we can start with little bit of copy paste action. Save file, we'll change that to save HTML. HTKM nope, there we go. We'll add a Shift in there. And in this case we'll say, save-html. In the renderer process, we do need to refactor out this function.
>> Steve Kinney: const saveHTML.

[00:00:56]
>> Steve Kinney: Oops, I got a little carried away there. There we go. And we'll go ahead and we'll say saveHTML.
>> Steve Kinney: For ipcRenderer, we'll say on save-html message, go ahead and save the HTML. All right, we'll go ahead and we'll kill that.
>> Steve Kinney: Check the menu up here. We've got this new Save HTML.

[00:01:37]
>> Steve Kinney: Cool, you can see that we've got now this, fit the HTML in there automatically, cuz it's calling the same code path.
>> Steve Kinney: We don't update anything, check my desktop. [NOISE] There it is with our Hello World. Awesome, and with that we've got most of an application. Obviously, we could fill out the rest of the menu a little bit more, build that out.

[00:02:06] New File could either do one of two things. It could open another window or it could just reset everything in here as it was if we open up a brand new window. There's a little bit of places to kind of play around and extend this. But I think we've gotten most of the functionality in place for a full desktop application that can read and write to the file system, create an application menu, open things in their native applications, show things in the finder, so on and so forth.

[00:02:29] So now, we're gonna kind of talk a little bit about some other things that we might want to do in Electron and build our second applications.