overwolf.os.tray API
Use this API for windows system tray related functionalities.
Methods Reference
- overwolf.os.tray.setMenu()
- overwolf.os.tray.changeIcon()
- overwolf.os.tray.changeIcon()
- overwolf.os.tray.restoreIcon()
- overwolf.os.tray.destroy()
Events Reference
- overwolf.os.tray.onMenuItemClicked
- overwolf.os.tray.onTrayIconClicked
- overwolf.os.tray.onTrayIconDoubleClicked
Types Reference
- ExtensionTrayMenu Object
- overwolf.os.tray.onMenuItemClickedEvent Object
- overwolf.os.tray.menu_item Object
setMenu(menu, callback)
Version added: 0.131
Permissions required: Tray
Create a tray icon for the calling extension with the supplied context menu object.
Parameter | Type | Description |
---|---|---|
menu | ExtensionTrayMenu object | The menu object |
callback | (Result) => void | Returns with the result |
Usage Example
const trayMenu = {
"menu_items": [{
"label": "View main window",
"id": "view_window"
}
]
}
overwolf.os.tray.setMenu(trayMenu, (res) => {
console.log("setMenu -> res", res)
});
Notes
- A launcher_icon must be set in the manifest.
- Calling setMenu() is mandatory to get a tray icon.
changeIcon(path, callback)
Version added: 0.208
An app's tray icon cannot be changed before it has one. You must call overwolf.os.tray.setMenu() before you can use this method!
Changes the tray icon for the app temporarily.
Parameter | Type | Description |
---|---|---|
path | string | Path for the new tray icon, relative to the app's install directory. |
callback | (Result) => void | Returns with the result of the operation |
changeIcon(space, path, callback)
Version added: 0.208
An app's tray icon cannot be changed before it has one. You must call overwolf.os.tray.setMenu() before you can use this method!
Changes the tray icon for the app temporarily, using a StorageSpace enum.
Parameter | Type | Description |
---|---|---|
space | StorageSpace enum | Space to look for the new icon. |
path | string | Path for the new tray icon, relative to space . |
callback | (Result) => void | Returns with the result of the operation |
restoreIcon(callback)
Version added: 0.208
An app's tray icon cannot be changed before it has one. You must call overwolf.os.tray.setMenu() before you can use this method!
Reverts the temporariy app tray icon back to the manifest-defined
tray_icon
.
Parameter | Type | Description |
---|---|---|
callback | (Result) => void | Returns with the result of the operation |
destroy()
Version added: 0.173
Permissions required: Tray
Destroys the tray icon immediately.
Parameter | Type | Description |
---|---|---|
none | none | no params |
ExtensionTrayMenu Object
A container object for a menu.
Parameter | Type | Description |
---|---|---|
menu_items | menu_item[] | array of menu items |
An example for a menu with sub items:
{
"menu_items": [{
"label": "View main window",
"id": "view_window"
},
{
"label": "More...",
"enabled": true,
"sub_items": [{
"label": "Version 1.0.0",
"id": "more_version",
"enabled": false
}]
},
{
"label": "-"
},
{
"label": "Visit website",
"id": "more_website"
}
]
}
menu_item Object
A container object for a menu item.
Parameter | Type | Description |
---|---|---|
id | string | must be set for items without "sub_items". (Separators and items with sub_items don't need ids) |
label | string | in order to create a separator, use the label "-" |
enabled | boolean | set to true by default |
sub_items | menu_item[] | you can nest an array of menu items under this item |
An example of a menu objects with sub items:
{
"label": "More...",
"enabled": true,
"sub_items": [{
"label": "Version 1.0.0",
"id": "more_version",
"enabled": false
}]
}
onMenuItemClicked
Version added: 0.131
Fired when an item from the tray icon’s context menu is selected, with the following structure: onMenuItemClickedEvent Object
Event data example
{ "item": "id" }
onTrayIconClicked
Version added: 0.131
Fired when the tray icon is left clicked.
onTrayIconDoubleClicked
Version added: 0.131
Fired when the tray icon is double clicked.
onMenuItemClickedEvent Object
Parameter | Type | Description |
---|---|---|
item | string |