mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 08:17:05 +00:00
Merge pull request #15214 from niik/electron-menu-item-click
Fix Electron's MenuItem click signatures
This commit is contained in:
Vendored
+7
-3
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Electron v1.4.8
|
||||
// Project: http://electron.atom.io/
|
||||
// Definitions by: jedmao <https://github.com/jedmao/>, rhysd <https://rhysd.github.io>, Milan Burda <https://github.com/miniak/>, aliib <https://github.com/aliib>, Daniel Perez Alvarez <https://github.com/unindented>
|
||||
// Definitions by: jedmao <https://github.com/jedmao/>, rhysd <https://rhysd.github.io>, Milan Burda <https://github.com/miniak/>, aliib <https://github.com/aliib>, Daniel Perez Alvarez <https://github.com/unindented>, Markus Olsson <https://github.com/niik>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
@@ -2455,7 +2455,11 @@ declare namespace Electron {
|
||||
*/
|
||||
constructor(options: MenuItemOptions);
|
||||
|
||||
click: (menuItem: MenuItem, browserWindow: BrowserWindow, event: Event) => void;
|
||||
/**
|
||||
* A function that is fired when the MenuItem receives a click event
|
||||
*/
|
||||
click: (event: Event, browserWindow: BrowserWindow, webContents: WebContents) => void;
|
||||
|
||||
/**
|
||||
* Read-only property.
|
||||
*/
|
||||
@@ -2492,7 +2496,7 @@ declare namespace Electron {
|
||||
/**
|
||||
* Callback when the menu item is clicked.
|
||||
*/
|
||||
click?: (menuItem: MenuItem, browserWindow: BrowserWindow) => void;
|
||||
click?: (menuItem: MenuItem, browserWindow: BrowserWindow, event: Event) => void;
|
||||
/**
|
||||
* Can be normal, separator, submenu, checkbox or radio.
|
||||
*/
|
||||
|
||||
+11
-4
@@ -531,12 +531,19 @@ var winWindows = new BrowserWindow({
|
||||
// menu-item
|
||||
// https://github.com/atom/electron/blob/master/docs/api/menu-item.md
|
||||
|
||||
var menuItem = new MenuItem({});
|
||||
var menuItem = new MenuItem({
|
||||
click: (menuItem: Electron.MenuItem, browserWindow: Electron.BrowserWindow, event: Electron.Event) => {
|
||||
console.log('click', menuItem, browserWindow, event);
|
||||
}
|
||||
});
|
||||
|
||||
const fakeEvent: Electron.Event = {
|
||||
preventDefault: () => { },
|
||||
sender: winWindows.webContents,
|
||||
}
|
||||
|
||||
menuItem.label = 'Hello World!';
|
||||
menuItem.click = (menuItem, browserWindow) => {
|
||||
console.log('click', menuItem, browserWindow);
|
||||
};
|
||||
menuItem.click(fakeEvent, winWindows, winWindows.webContents)
|
||||
|
||||
// menu
|
||||
// https://github.com/atom/electron/blob/master/docs/api/menu.md
|
||||
|
||||
Reference in New Issue
Block a user