DefinitelyTyped/github-electron/github-electron.menu.d.ts
2016-03-26 02:11:19 +01:00

64 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Type definitions for Electron v0.37.2
// Project: http://electron.atom.io/
// Definitions by: jedmao <https://github.com/jedmao/>, rhysd <https://rhysd.github.io>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="github-electron.browser-window.d.ts" />
/// <reference path="github-electron.event-emitter.d.ts" />
/// <reference path="github-electron.menu-item.d.ts" />
declare namespace Electron {
/**
* The Menu class is used to create native menus that can be used as application
* menus and context menus. This module is a main process module which can be used
* in a render process via the remote module.
*
* Each menu consists of multiple menu items, and each menu item can have a submenu.
*/
class Menu extends EventEmitter {
/**
* Creates a new menu.
*/
constructor();
/**
* Sets menu as the application menu on OS X. On Windows and Linux, the menu
* will be set as each window's top menu.
*/
static setApplicationMenu(menu: Menu): void;
/**
* Sends the action to the first responder of application.
* This is used for emulating default Cocoa menu behaviors,
* usually you would just use the role property of MenuItem.
*
* Note: This method is OS X only.
*/
static sendActionToFirstResponder(action: string): void;
/**
* @param template Generally, just an array of options for constructing MenuItem.
* You can also attach other fields to element of the template, and they will
* become properties of the constructed menu items.
*/
static buildFromTemplate(template: MenuItemOptions[]): Menu;
/**
* Popups this menu as a context menu in the browserWindow. You can optionally
* provide a (x,y) coordinate to place the menu at, otherwise it will be placed
* at the current mouse cursor position.
* @param x Horizontal coordinate where the menu will be placed.
* @param y Vertical coordinate where the menu will be placed.
*/
popup(browserWindow?: BrowserWindow, x?: number, y?: number): void;
/**
* Appends the menuItem to the menu.
*/
append(menuItem: MenuItem): void;
/**
* Inserts the menuItem to the pos position of the menu.
*/
insert(position: number, menuItem: MenuItem): void;
/**
* @returns an array containing the menus items.
*/
items: MenuItem[];
}
}