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:

Parameter Type Description
event "balloon-click" The event name.
listener () => void The 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:

Parameter Type Description
event "balloon-closed" The event name.
listener () => void The 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:

Parameter Type Description
event "balloon-show" The event name.
listener () => void The 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:

Parameter Type Description
event "click" The event name.
listener (event: ElectronKeyboardEvent, bounds: ElectronRectangle, position: ElectronPoint) => void The 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:

Parameter Type Description
event "double-click" The event name.
listener (event: ElectronKeyboardEvent, bounds: ElectronRectangle) => void The 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:

Parameter Type Description
event "drag-end" The event name.
listener () => void The 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:

Parameter Type Description
event "drag-enter" The event name.
listener () => void The 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:

Parameter Type Description
event "drag-leave" The event name.
listener () => void The 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:

Parameter Type Description
event "drop" The event name.
listener () => void The 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:

Parameter Type Description
event "drop-files" The event name.
listener (event: ElectronEvent, files: string[]) => void The 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:

Parameter Type Description
event "drop-text" The event name.
listener (event: ElectronEvent, text: string) => void The 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:

Parameter Type Description
event "mouse-down" The event name.
listener (event: ElectronKeyboardEvent, position: ElectronPoint) => void The 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:

Parameter Type Description
event "mouse-enter" The event name.
listener (event: ElectronKeyboardEvent, position: ElectronPoint) => void The 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:

Parameter Type Description
event "mouse-leave" The event name.
listener (event: ElectronKeyboardEvent, position: ElectronPoint) => void The 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:

Parameter Type Description
event "mouse-move" The event name.
listener (event: ElectronKeyboardEvent, position: ElectronPoint) => void The 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:

Parameter Type Description
event "mouse-up" The event name.
listener (event: ElectronKeyboardEvent, position: ElectronPoint) => void The 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:

Parameter Type Description
event "right-click" The event name.
listener (event: ElectronKeyboardEvent, bounds: ElectronRectangle) => void The event handler receiving the event and the bounds of the tray icon.

Returns: thisThis tray instance.