Ende.Tray
interface · desktop apps only
interface Ende.Tray extends TrayEventHandlersclass · desktop apps only
class Ende.Tray extends EventTarget implements DisposableA persistent icon in the OS status area (macOS menu bar extras, Windows system tray, Linux AppIndicator).
The icon is removed from the OS when Tray.destroy is
called. Multiple trays may be created.
Constructors
constructor
new Tray()Properties
trayId
readonly trayId: numberMethods
setIcon
setIcon(pngBytes: Uint8Array): voidSet the tray icon image from PNG-encoded bytes.
setIconDark
setIconDark(pngBytes: Uint8Array | null): voidSet the tray icon used in OS dark mode. Pass null to clear
it.
setTooltip
setTooltip(text: string | null): voidSet the tooltip shown on hover. Pass null or an empty string
to clear the tooltip.
setMenu
setMenu(menu: MenuItem[] | null): voidSet the right-click context menu. Click events are delivered as
"menuclick" events on the tray. Pass null to remove any
menu previously set.
getBounds
getBounds(): TrayBounds | nullThe tray icon's bounding rectangle in screen coordinates, or null
if the icon has no on-screen position yet or the platform can't report
it. Typically called from a "click" handler to position a popover
BrowserWindow (created with frameless + noActivate)
under the icon.
attachPanel
attachPanel(options: TrayPanelOptions | string): TrayPanelAttach a frameless, non-activating popover window to this tray icon
(the classic menu-bar-app pattern). The returned panel toggles on tray
click, is positioned under the icon via Tray.getBounds, and
hides when it loses focus.
Convenience built on the primitives; for full control create a
frameless + noActivate BrowserWindow yourself.
const tray = new Ende.Tray();
tray.setIcon(iconBytes);
const panel = tray.attachPanel({ url: "https://localhost:8000/panel" });
panel.window.bind("doThing", async () => { ... });
Pass a string as shorthand for { url }. On Linux the icon position
can't be queried, so the panel shows at its last position rather than
anchored to the icon.
destroy
destroy(): voidRemove the tray icon from the OS status area. The instance must not be used after this call.
[Symbol.dispose]
[Symbol.dispose](): voidaddEventListener
addEventListener<K extends keyof TrayEventMap>(type: K, listener: (this: Tray, ev: TrayEventMap[K]) => any, options?: boolean | AddEventListenerOptions): voidaddEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): voidremoveEventListener
removeEventListener<K extends keyof TrayEventMap>(type: K, listener: (this: Tray, ev: TrayEventMap[K]) => any, options?: boolean | EventListenerOptions): voidremoveEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void