Skip to content
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

docs: Adds Customize Menu section Fiddle example #20468

Merged
merged 1 commit into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions docs/fiddles/menus/customize-menus/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Customize Menus</title>
</head>

<body>
<div class="section-wrapper">
<h1>Customize Menus</h1>

<h3>
The <code>Menu</code> and <code>MenuItem</code> modules can be used to
create custom native menus.
</h3>

<p>
There are two kinds of menus: the application (top) menu and context
(right-click) menu.
</p>

<p>
Open the
<a href="http://electron.atom.io/docs/api/menu"
>full API documentation<span class="u-visible-to-screen-reader"
>(opens in new window)</span
></a
>
in your browser.
</p>
</div>

yashints marked this conversation as resolved.
Show resolved Hide resolved
<div class="demo">
<h2>Create an application menu</h2>
<div class="demo-wrapper">
<div class="demo-box">
<p>
The <code>Menu</code> and <code>MenuItem</code> modules allow you to
customize your application menu. If you don't set any menu, Electron
will generate a minimal menu for your app by default.
</p>

<p>
If you click the 'View' option in the application menu and then the
'App Menu Demo', you'll see an information box displayed.
</p>

<div class="demo-protip">
<h2>ProTip</h2>
<strong>Know operating system menu differences.</strong>
<p>
When designing an app for multiple operating systems it's
important to be mindful of the ways application menu conventions
differ on each operating system.
</p>
<p>
For instance, on Windows, accelerators are set with an
<code>&</code>. Naming conventions also vary, like between
"Settings" or "Preferences". Below are resources for learning
operating system specific standards.
</p>
<ul>
<li>
<a
href="https://developer.apple.com/macos/human-interface-guidelines/menus/menu-anatomy/"
>macOS<span class="u-visible-to-screen-reader"
>(opens in new window)</span
></a
>
</li>
<li>
<a
href="https://msdn.microsoft.com/en-us/library/windows/desktop/bb226797(v=vs.85).aspx"
>Windows<span class="u-visible-to-screen-reader"
>(opens in new window)</span
></a
>
</li>
<li>
<a
href="https://developer.gnome.org/hig/stable/menu-bars.html.en"
>Linux<span class="u-visible-to-screen-reader"
>(opens in new window)</span
></a
>
</li>
</ul>
</div>
</div>
</div>
</div>

yashints marked this conversation as resolved.
Show resolved Hide resolved
<div class="demo">
<h2>Create a context menu</h2>
<div class="demo-wrapper">
<div class="demo-box">
<div class="demo-controls">
<button class="demo-button" id="context-menu">View Demo</button>
</div>
<p>
A context, or right-click, menu can be created with the
<code>Menu</code> and <code>MenuItem</code> modules as well. You can
right-click anywhere in this app or click the demo button to see an
example context menu.
</p>

<p>
In this demo we use the <code>ipcRenderer</code> module to show the
context menu when explicitly calling it from the renderer process.
</p>
<p>
See the full
<a
href="http://electron.atom.io/docs/api/web-contents/#event-context-menu"
>context-menu event documentation</a
>
for all the available properties.
</p>
</div>
</div>
</div>

<script>
// You can also require other files to run in this process
require("./renderer.js");
</script>
</body>
</html>
Loading