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"The event name.
listener() => voidThe event handler.

Returns: thisThis 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"The event name.
listener() => voidThe event handler.

Returns: thisThis 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"The event name.
listener() => voidThe event handler.

Returns: thisThis 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"The event name.
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: thisThis 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"The event name.
listener(event: ElectronKeyboardEvent, bounds: ElectronRectangle) => voidThe event handler receiving the event and the bounds of the tray icon.

Returns: thisThis 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"The event name.
listener() => voidThe event handler.

Returns: thisThis 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"The event name.
listener() => voidThe event handler.

Returns: thisThis 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"The event name.
listener() => voidThe event handler.

Returns: thisThis 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"The event name.
listener() => voidThe event handler.

Returns: thisThis 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"The event name.
listener(event: ElectronEvent, files: string[]) => voidThe event handler receiving the event and the paths of the dropped files.

Returns: thisThis 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"The event name.
listener(event: ElectronEvent, text: string) => voidThe event handler receiving the event and the dropped text string.

Returns: thisThis 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"The event name.
listener(event: ElectronKeyboardEvent, position: ElectronPoint) => voidThe event handler receiving the event and the position of the event.

Returns: thisThis 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"The event name.
listener(event: ElectronKeyboardEvent, position: ElectronPoint) => voidThe event handler receiving the event and the position of the event.

Returns: thisThis 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"The event name.
listener(event: ElectronKeyboardEvent, position: ElectronPoint) => voidThe event handler receiving the event and the position of the event.

Returns: thisThis 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"The event name.
listener(event: ElectronKeyboardEvent, position: ElectronPoint) => voidThe event handler receiving the event and the position of the event.

Returns: thisThis 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"The event name.
listener(event: ElectronKeyboardEvent, position: ElectronPoint) => voidThe event handler receiving the event and the position of the event.

Returns: thisThis 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"The event name.
listener(event: ElectronKeyboardEvent, bounds: ElectronRectangle) => voidThe event handler receiving the event and the bounds of the tray icon.

Returns: thisThis tray instance.