Skip to content

ElectronTray

Unofficial

Electron Tray for adding icons and context menus to the system’s notification area.

Import:

import type { ElectronTray } from '@obsidian-typings/obsidian-public-latest';

Signature:

export class ElectronTray

Methods

MethodReturnsDescription
addListener(event, listener)thisRegisters an event listener that is invoked when the tray balloon is clicked. win32 only.
addListener(event, listener)thisRegisters an event listener that is invoked when the tray balloon is closed because of timeout or user manually closes it. win32 only.
addListener(event, listener)thisRegisters an event listener that is invoked when the tray balloon shows. win32 only.
addListener(event, listener)thisRegisters an event listener that is invoked when the tray icon is clicked.
addListener(event, listener)thisRegisters an event listener that is invoked when the tray icon is double clicked. darwin and win32 only.
addListener(event, listener)thisRegisters an event listener that is invoked when a drag operation ends on the tray or ends at another location. darwin only.
addListener(event, listener)thisRegisters an event listener that is invoked when a drag operation enters the tray icon. darwin only.
addListener(event, listener)thisRegisters an event listener that is invoked when a drag operation exits the tray icon. darwin only.
addListener(event, listener)thisRegisters an event listener that is invoked when any dragged items are dropped on the tray icon. darwin only.
addListener(event, listener)thisRegisters an event listener that is invoked when dragged files are dropped in the tray icon. darwin only.
addListener(event, listener)thisRegisters an event listener that is invoked when dragged text is dropped in the tray icon. darwin only.
addListener(event, listener)thisRegisters an event listener that is invoked when the mouse clicks the tray icon. darwin only.
addListener(event, listener)thisRegisters an event listener that is invoked when the mouse enters the tray icon. darwin only.
addListener(event, listener)thisRegisters an event listener that is invoked when the mouse exits the tray icon. darwin only.
addListener(event, listener)thisRegisters an event listener that is invoked when the mouse moves in the tray icon. darwin and win32 only.
addListener(event, listener)thisRegisters an event listener that is invoked when the mouse is released from clicking the tray icon.

Note: This will not be emitted if you have set a context menu for your tray using ElectronTray.setContextMenu, as a result of macOS-level constraints. darwin only.
addListener(event, listener)thisRegisters an event listener that is invoked when the tray icon is right clicked. darwin and win32 only.
closeContextMenu()voidCloses an open context menu, as set by ElectronTray.setContextMenu. darwin and win32 only.
destroy()voidDestroys the tray icon immediately.
displayBalloon(options)voidDisplays a tray balloon. win32 only.
focus()voidReturns focus to the taskbar notification area. Notification area icons should use this message when they have completed their UI operation. For example, if the icon displays a shortcut menu, but the user presses ESC to cancel it, use tray.focus() to return focus to the notification area. win32 only.
getBounds()ElectronRectangleThe bounds of this tray icon. darwin and win32 only.
getIgnoreDoubleClickEvents()booleanWhether double click events will be ignored. darwin only.
getTitle()stringThe title displayed next to the tray icon in the status bar. darwin only.
isDestroyed()booleanWhether the tray icon is destroyed.
on('balloon-click', listener)thisRegisters a listener that is invoked when the tray balloon is clicked. win32 only.
on('balloon-closed', listener)thisRegisters a listener that is invoked when the tray balloon is closed because of timeout or user manually closes it. win32 only.
on('balloon-show', listener)thisRegisters a listener that is invoked when the tray balloon shows. win32 only.
on('click', listener)thisRegisters a listener that is invoked when the tray icon is clicked.
on('double-click', listener)thisRegisters a listener that is invoked when the tray icon is double clicked. darwin and win32 only.
on('drag-end', listener)thisRegisters a listener that is invoked when a drag operation ends on the tray or ends at another location. darwin only.
on('drag-enter', listener)thisRegisters a listener that is invoked when a drag operation enters the tray icon. darwin only.
on('drag-leave', listener)thisRegisters a listener that is invoked when a drag operation exits the tray icon. darwin only.
on('drop', listener)thisRegisters a listener that is invoked when any dragged items are dropped on the tray icon. darwin only.
on('drop-files', listener)thisRegisters a listener that is invoked when dragged files are dropped in the tray icon. darwin only.
on('drop-text', listener)thisRegisters a listener that is invoked when dragged text is dropped in the tray icon. darwin only.
on('mouse-down', listener)thisRegisters a listener that is invoked when the mouse clicks the tray icon. darwin only.
on('mouse-enter', listener)thisRegisters a listener that is invoked when the mouse enters the tray icon. darwin only.
on('mouse-leave', listener)thisRegisters a listener that is invoked when the mouse exits the tray icon. darwin only.
on('mouse-move', listener)thisRegisters a listener that is invoked when the mouse moves in the tray icon. darwin and win32 only.
on('mouse-up', listener)thisRegisters a listener that is invoked when the mouse is released from clicking the tray icon.

Note: This will not be emitted if you have set a context menu for your tray using ElectronTray.setContextMenu, as a result of macOS-level constraints. darwin only.
on('right-click', listener)thisRegisters a listener that is invoked when the tray icon is right clicked. darwin and win32 only.
once(event, listener)thisRegisters a one-time listener that is invoked when the tray balloon is clicked. win32 only.
once(event, listener)thisRegisters a one-time listener that is invoked when the tray balloon is closed because of timeout or user manually closes it. win32 only.
once(event, listener)thisRegisters a one-time listener that is invoked when the tray balloon shows. win32 only.
once(event, listener)thisRegisters a one-time listener that is invoked when the tray icon is clicked.
once(event, listener)thisRegisters a one-time listener that is invoked when the tray icon is double clicked. darwin and win32 only.
once(event, listener)thisRegisters a one-time listener that is invoked when a drag operation ends on the tray or ends at another location. darwin only.
once(event, listener)thisRegisters a one-time listener that is invoked when a drag operation enters the tray icon. darwin only.
once(event, listener)thisRegisters a one-time listener that is invoked when a drag operation exits the tray icon. darwin only.
once(event, listener)thisRegisters a one-time listener that is invoked when any dragged items are dropped on the tray icon. darwin only.
once(event, listener)thisRegisters a one-time listener that is invoked when dragged files are dropped in the tray icon. darwin only.
once(event, listener)thisRegisters a one-time listener that is invoked when dragged text is dropped in the tray icon. darwin only.
once(event, listener)thisRegisters a one-time listener that is invoked when the mouse clicks the tray icon. darwin only.
once(event, listener)thisRegisters a one-time listener that is invoked when the mouse enters the tray icon. darwin only.
once(event, listener)thisRegisters a one-time listener that is invoked when the mouse exits the tray icon. darwin only.
once(event, listener)thisRegisters a one-time listener that is invoked when the mouse moves in the tray icon. darwin and win32 only.
once(event, listener)thisRegisters a one-time listener that is invoked when the mouse is released from clicking the tray icon.

Note: This will not be emitted if you have set a context menu for your tray using ElectronTray.setContextMenu, as a result of macOS-level constraints. darwin only.
once(event, listener)thisRegisters a one-time listener that is invoked when the tray icon is right clicked. darwin and win32 only.
popUpContextMenu(menu?, position?)voidPops up the context menu of the tray icon. When menu is passed, the menu will be shown instead of the tray icon's context menu.

The position is only available on Windows, and it is (0, 0) by default. darwin and win32 only.
removeBalloon()voidRemoves a tray balloon. win32 only.
removeListener(event, listener)thisRemoves the event listener for the tray balloon being clicked.
removeListener(event, listener)thisRemoves the event listener for the tray balloon being closed.
removeListener(event, listener)thisRemoves the event listener for the tray balloon being shown.
removeListener(event, listener)thisRemoves the event listener for the tray icon being clicked.
removeListener(event, listener)thisRemoves the event listener for the tray icon being double clicked.
removeListener(event, listener)thisRemoves the event listener for a drag operation ending.
removeListener(event, listener)thisRemoves the event listener for a drag operation entering the tray icon.
removeListener(event, listener)thisRemoves the event listener for a drag operation exiting the tray icon.
removeListener(event, listener)thisRemoves the event listener for dragged items being dropped on the tray icon.
removeListener(event, listener)thisRemoves the event listener for dragged files being dropped in the tray icon.
removeListener(event, listener)thisRemoves the event listener for dragged text being dropped in the tray icon.
removeListener(event, listener)thisRemoves the event listener for the mouse clicking the tray icon.
removeListener(event, listener)thisRemoves the event listener for the mouse entering the tray icon.
removeListener(event, listener)thisRemoves the event listener for the mouse exiting the tray icon.
removeListener(event, listener)thisRemoves the event listener for the mouse moving in the tray icon.
removeListener(event, listener)thisRemoves the event listener for the mouse being released from clicking the tray icon.
removeListener(event, listener)thisRemoves the event listener for the tray icon being right clicked.
setContextMenu(menu)voidSets the context menu for this icon.
setIgnoreDoubleClickEvents(ignore)voidSets the option to ignore double click events. Ignoring these events allows you to detect every individual click of the tray icon. darwin only.
setImage(image)voidSets the image associated with this tray icon.
setPressedImage(image)voidSets the image associated with this tray icon when pressed on macOS. darwin only.
setTitle(title, options?)voidSets the title displayed next to the tray icon in the status bar (Support ANSI colors). darwin only.
setToolTip(toolTip)voidSets the hover text for this tray icon.

Links to this page: