From 1bde04c781fc96b3d1d103f192ad2191fbcbe1b0 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Fri, 25 Mar 2016 21:07:43 +0100 Subject: [PATCH] Update tray module --- github-electron/github-electron-main-tests.ts | 13 ++++ github-electron/github-electron.tray.d.ts | 78 ++++++++++++++++++- 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/github-electron/github-electron-main-tests.ts b/github-electron/github-electron-main-tests.ts index 568938d405..0b9c20c267 100644 --- a/github-electron/github-electron-main-tests.ts +++ b/github-electron/github-electron-main-tests.ts @@ -505,6 +505,19 @@ app.on('ready', () => { appIcon.setToolTip('This is my application.'); appIcon.setContextMenu(contextMenu); appIcon.setImage('/path/to/new/icon'); + appIcon.popUpContextMenu(contextMenu, {x: 100, y: 100}); + + appIcon.on('click', (event, bounds) => { + console.log('click', event, bounds); + }); + + appIcon.on('ballon-show', () => { + console.log('ballon-show'); + }); + + appIcon.displayBalloon({ + title: 'Hello World!' + }); }); // clipboard diff --git a/github-electron/github-electron.tray.d.ts b/github-electron/github-electron.tray.d.ts index bf2d0a881c..0cbad09a5e 100644 --- a/github-electron/github-electron.tray.d.ts +++ b/github-electron/github-electron.tray.d.ts @@ -6,10 +6,69 @@ /// /// /// +/// declare namespace Electron { - + /** + * A Tray represents an icon in an operating system's notification area. + */ class Tray extends EventEmitter { + /** + * Emitted when the tray icon is clicked. + * Note: The bounds payload is only implemented on OS X and Windows. + */ + on(event: 'click', listener: (modifiers: Modifiers, bounds: Bounds) => void): this; + /** + * Emitted when the tray icon is right clicked. + * Note: This is only implemented on OS X and Windows. + */ + on(event: 'right-click', listener: (modifiers: Modifiers, bounds: Bounds) => void): this; + /** + * Emitted when the tray icon is double clicked. + * Note: This is only implemented on OS X and Windows. + */ + on(event: 'double-click', listener: (modifiers: Modifiers, bounds: Bounds) => void): this; + /** + * Emitted when the tray balloon shows. + * Note: This is only implemented on Windows. + */ + on(event: 'balloon-show', listener: Function): this; + /** + * Emitted when the tray balloon is clicked. + * Note: This is only implemented on Windows. + */ + on(event: 'balloon-click', listener: Function): this; + /** + * Emitted when the tray balloon is closed because of timeout or user manually closes it. + * Note: This is only implemented on Windows. + */ + on(event: 'balloon-closed', listener: Function): this; + /** + * Emitted when any dragged items are dropped on the tray icon. + * Note: This is only implemented on OS X. + */ + on(event: 'drop', listener: Function): this; + /** + * Emitted when dragged files are dropped in the tray icon. + * Note: This is only implemented on OS X + */ + on(event: 'drop-files', listener: (event: Event, files: string[]) => void): this; + /** + * Emitted when a drag operation enters the tray icon. + * Note: This is only implemented on OS X + */ + on(event: 'drag-enter', listener: Function): this; + /** + * Emitted when a drag operation exits the tray icon. + * Note: This is only implemented on OS X + */ + on(event: 'drag-leave', listener: Function): this; + /** + * Emitted when a drag operation ends on the tray or ends at another location. + * Note: This is only implemented on OS X + */ + on(event: 'drag-end', listener: Function): this; + on(event: string, listener: Function): this; /** * Creates a new tray icon associated with the image. */ @@ -49,9 +108,26 @@ declare namespace Electron { title?: string; content?: string; }): void; + /** + * Popups the context menu of tray icon. When menu is passed, + * the menu will showed instead of the tray's context menu. + * The position is only available on Windows, and it is (0, 0) by default. + * Note: This is only implemented on OS X and Windows. + */ + popUpContextMenu(menu?: Menu, position?: { + x: number; + y: number; + }): void; /** * Sets the context menu for this icon. */ setContextMenu(menu: Menu): void; } + + interface Modifiers { + altKey: boolean; + shiftKey: boolean; + ctrlKey: boolean; + metaKey: boolean; + } }