Cocos Creator API

0.7.1

Cocos Creator is a highly customizable game development tool that utilizes the power of cocos2d-x.

Menu

Module: Editor

Methods

Menu
(
  • template
  • [webContents ]
)
Menu

name type description
template object[] | object

Menu template for initialize. The template take the options of Electron's Menu Item plus the following properties.

  • path string
    add a menu item by path.
  • message string
    Ipc message name.
  • command string
    A global function in core level (e.g. Editor.foo.bar ).
  • params array
    The parameters passed through ipc.
  • panel string
    The panelID, if specified, the message will send to panel.
  • dev string
    Only show when Editor.isDev is true.
webContents optional object

A WebContents object.

returns:

type: Menu

dispose ( )

De-reference the native menu.

reset
(
  • template
)

Reset the menu from the template.

name type description
template object[] | object

clear ( )

Clear all menu item in it.

add
(
  • path
  • template
)

Build a template into menu item and add it to path

name type description
path string

A menu path

template object[] | object

examples:

let editorMenu = new Editor.Menu();
editorMenu.add( 'foo/bar', {
  label: foobar,
  message: 'foobar:say',
  params: ['foobar: hello!']
});

// you can also create menu without label
// it will add menu to foo/bar where bar is the menu-item
let editorMenu = new Editor.Menu();
editorMenu.add( 'foo/bar/foobar', {
  message: 'foobar:say',
  params: ['foobar: hello!']
});

remove
(
  • path
)

Remove menu item at path.

name type description
path string

A menu path

set
(
  • path
  • [options ]
)

Set menu options at path.

name type description
path string

A menu path

options optional object
  • icon NativeImage optional
    A [NativeImage](https://github.com/atom/electron/blob/master/docs/api/native-image.md)
  • enabled Boolean optional
  • visible Boolean optional
  • checked Boolean optional
    NOTE: You must set your menu-item type to 'checkbox' to make it work

convert
(
  • template
  • [webContents ]
)

Convert the menu template to process additional keyword we added for Electron. If webContents provided, the template.message will send to the target webContents.

name type description
template object[] | object
webContents optional object

A WebContents object.

register
(
  • name
  • fn
  • [force ]
)
static

name type description
name string

name of the register menu

fn function

a function returns the menu template

force optional boolean

force to register a menu even it was registered before.

getMenu
(
  • name
)
static

name type description
name string

Name of the register menu

walk
(
  • template
  • fn
)
static

name type description
template object[] | object
fn function

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index