]> khamidou — GitHub mirrors - electron.git/commitdiff
:memo: Fix the outdated menu example, closed #389.
authorCheng Zhao <zcbenz@gmail.com>
Tue, 10 Jun 2014 05:29:09 +0000 (13:29 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 10 Jun 2014 05:29:09 +0000 (13:29 +0800)
docs/api/menu.md

index 54825d6fefe36a1d612f0e254028d7e69c5bf55f..49fb507c63d01229adafdd11527262f41b9d8c53 100644 (file)
@@ -4,12 +4,16 @@ The `Menu` class is used to create native menus that can be used as
 application menu and context menu. Each menu is consisted of multiple menu
 items, and each menu item can have a submenu.
 
-An example of creating a menu dynamically and show it when user right clicks
+An example of creating a menu dynamically in web page by using the
+[remote](remote.md) module, and show it when user right clicks
 the page:
 
-```javascript
-var Menu = require('menu');
-var MenuItem = require('menu-item');
+```html
+<!-- index.html -->
+<script>
+var remote = require('remote');
+var Menu = remote.require('menu');
+var MenuItem = remote.require('menu-item');
 
 var menu = new Menu();
 menu.append(new MenuItem({ label: 'MenuItem1', click: function() { console.log('item 1 clicked'); } }));
@@ -18,13 +22,15 @@ menu.append(new MenuItem({ label: 'MenuItem2', type: 'checkbox', checked: true }
 
 window.addEventListener('contextmenu', function (e) {
   e.preventDefault();
-  menu.popup();
+  menu.popup(remote.getCurrentWindow());
 }, false);
+</script>
 ```
 
 Another example of creating the application menu with the simple template API:
 
 ```javascript
+// main.js
 var template = [
   {
     label: 'Atom Shell',