Electron Fundamentals, v2 Menu Roles
This course is out of date and does not reflect our standards or industry best practices.
Transcript from the "Menu Roles" Lesson
>> Steve Kinney: Another really interesting one is, actually let's go over to Electron docs.
>> Steve Kinney: There is a built in role, that we can use because you certainly do not want to implement your own version of copy or paste or select all, right? These work in just general text areas, in Chrome, there's no reason why you should have to write your own.
[00:00:34] So for some of these operating system level features, these roles, you basically say, hey I wanna create this menu item. And if it is one of these kind of like built in things, you can go ahead and use that role. An electron we'll call the native OS ability to do that thing.
[00:00:55] So you can see there's a role for quit, that's interesting. There is an entire edit menu. The entire window menu. There's one for closing a window, minimizing, all of these right here. Paste and match style, which I think was not in the default menu, select all, so on and so forth.
[00:01:12] So you can put these menu items where ever you want. You can give them their own hotkeys, everything along those lines. Let's actually try that with the quit, so instead of this, we'll actually say role,
>> Steve Kinney: Quit, quite, quit. And here we'll actually say, role about. And just for our Windows, let's say, let's add one more, we'll add it to the file menu.
[00:01:39] For now, say label, we'll go with Copy.
>> Steve Kinney: The role copy, all right.
>> Steve Kinney: Then now we can close this. You could also put the quit menu on file if you wanted to. So, actually gave us dictation and emotions and symbols as well we had copy in there, those are usually in the edit menu.
[00:02:11] You can see that with the quit, it actually give us the command q as well. It just basically did everything you would normally expect, it's just a shortcut of what you would normally expect the operating system to do, with a quit menu. About, actually, in Mac OS, we'll pull up this little about.
>> Steve Kinney: It can take some text.
>> Steve Kinney: Manually select all, go to copy, paste it in, and I have some text. So you can start of like reimplement some of the menus in this case.