Skip to content

ElectronTray.once method

ElectronTray › once

Unofficial

Registers a one-time listener that is invoked when the tray balloon is clicked. win32 only.

Signature:

once($event: "balloon-click", listener: () => void): this

Parameters:

ParameterTypeDescription
$event"balloon-click"
listener() => voidThe event handler.

Returns: this — This tray instance.


Unofficial

Registers a one-time listener that is invoked when the tray balloon is closed because of timeout or user manually closes it. win32 only.

Signature:

once($event: "balloon-closed", listener: () => void): this

Parameters:

ParameterTypeDescription
$event"balloon-closed"
listener() => voidThe event handler.

Returns: this — This tray instance.


Unofficial

Registers a one-time listener that is invoked when the tray balloon shows. win32 only.

Signature:

once($event: "balloon-show", listener: () => void): this

Parameters:

ParameterTypeDescription
$event"balloon-show"
listener() => voidThe event handler.

Returns: this — This tray instance.


Unofficial

Registers a one-time listener that is invoked when the tray icon is clicked.

Signature:

once($event: "click", listener: ($event: ElectronKeyboardEvent, bounds: ElectronRectangle, position: ElectronPoint) => void): this

Parameters:

ParameterTypeDescription
$event"click"
listener($event: ElectronKeyboardEvent, bounds: ElectronRectangle, position: ElectronPoint) => voidThe event handler receiving the event, the bounds of the tray icon, and the position of the event.

Returns: this — This tray instance.


Unofficial

Registers a one-time listener that is invoked when the tray icon is double clicked. darwin and win32 only.

Signature:

once($event: "double-click", listener: ($event: ElectronKeyboardEvent, bounds: ElectronRectangle) => void): this

Parameters:

ParameterTypeDescription
$event"double-click"
listener($event: ElectronKeyboardEvent, bounds: ElectronRectangle) => voidThe event handler receiving the event and the bounds of the tray icon.

Returns: this — This tray instance.


Unofficial

Registers a one-time listener that is invoked when a drag operation ends on the tray or ends at another location. darwin only.

Signature:

once($event: "drag-end", listener: () => void): this

Parameters:

ParameterTypeDescription
$event"drag-end"
listener() => voidThe event handler.

Returns: this — This tray instance.


Unofficial

Registers a one-time listener that is invoked when a drag operation enters the tray icon. darwin only.

Signature:

once($event: "drag-enter", listener: () => void): this

Parameters:

ParameterTypeDescription
$event"drag-enter"
listener() => voidThe event handler.

Returns: this — This tray instance.


Unofficial

Registers a one-time listener that is invoked when a drag operation exits the tray icon. darwin only.

Signature:

once($event: "drag-leave", listener: () => void): this

Parameters:

ParameterTypeDescription
$event"drag-leave"
listener() => voidThe event handler.

Returns: this — This tray instance.


Unofficial

Registers a one-time listener that is invoked when any dragged items are dropped on the tray icon. darwin only.

Signature:

once($event: "drop", listener: () => void): this

Parameters:

ParameterTypeDescription
$event"drop"
listener() => voidThe event handler.

Returns: this — This tray instance.


Unofficial

Registers a one-time listener that is invoked when dragged files are dropped in the tray icon. darwin only.

Signature:

once($event: "drop-files", listener: ($event: ElectronEvent, files: string[]) => void): this

Parameters:

ParameterTypeDescription
$event"drop-files"
listener($event: ElectronEvent, files: string[]) => voidThe event handler receiving the event and the paths of the dropped files.

Returns: this — This tray instance.


Unofficial

Registers a one-time listener that is invoked when dragged text is dropped in the tray icon. darwin only.

Signature:

once($event: "drop-text", listener: ($event: ElectronEvent, text: string) => void): this

Parameters:

ParameterTypeDescription
$event"drop-text"
listener($event: ElectronEvent, text: string) => voidThe event handler receiving the event and the dropped text string.

Returns: this — This tray instance.


Unofficial

Registers a one-time listener that is invoked when the mouse clicks the tray icon. darwin only.

Signature:

once($event: "mouse-down", listener: ($event: ElectronKeyboardEvent, position: ElectronPoint) => void): this

Parameters:

ParameterTypeDescription
$event"mouse-down"
listener($event: ElectronKeyboardEvent, position: ElectronPoint) => voidThe event handler receiving the event and the position of the event.

Returns: this — This tray instance.


Unofficial

Registers a one-time listener that is invoked when the mouse enters the tray icon. darwin only.

Signature:

once($event: "mouse-enter", listener: ($event: ElectronKeyboardEvent, position: ElectronPoint) => void): this

Parameters:

ParameterTypeDescription
$event"mouse-enter"
listener($event: ElectronKeyboardEvent, position: ElectronPoint) => voidThe event handler receiving the event and the position of the event.

Returns: this — This tray instance.


Unofficial

Registers a one-time listener that is invoked when the mouse exits the tray icon. darwin only.

Signature:

once($event: "mouse-leave", listener: ($event: ElectronKeyboardEvent, position: ElectronPoint) => void): this

Parameters:

ParameterTypeDescription
$event"mouse-leave"
listener($event: ElectronKeyboardEvent, position: ElectronPoint) => voidThe event handler receiving the event and the position of the event.

Returns: this — This tray instance.


Unofficial

Registers a one-time listener that is invoked when the mouse moves in the tray icon. darwin and win32 only.

Signature:

once($event: "mouse-move", listener: ($event: ElectronKeyboardEvent, position: ElectronPoint) => void): this

Parameters:

ParameterTypeDescription
$event"mouse-move"
listener($event: ElectronKeyboardEvent, position: ElectronPoint) => voidThe event handler receiving the event and the position of the event.

Returns: this — This tray instance.


Unofficial

Registers 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.

Signature:

once($event: "mouse-up", listener: ($event: ElectronKeyboardEvent, position: ElectronPoint) => void): this

Parameters:

ParameterTypeDescription
$event"mouse-up"
listener($event: ElectronKeyboardEvent, position: ElectronPoint) => voidThe event handler receiving the event and the position of the event.

Returns: this — This tray instance.


Unofficial

Registers a one-time listener that is invoked when the tray icon is right clicked. darwin and win32 only.

Signature:

once($event: "right-click", listener: ($event: ElectronKeyboardEvent, bounds: ElectronRectangle) => void): this

Parameters:

ParameterTypeDescription
$event"right-click"
listener($event: ElectronKeyboardEvent, bounds: ElectronRectangle) => voidThe event handler receiving the event and the bounds of the tray icon.

Returns: this — This tray instance.