class TrayIcon
- Extends:
- UIComponent
Description:
TrayIcon is a system icon usually displayed in a tray of icons for applications running or capable of running in the background.
TrayIcon component is able to show system notification messages, have context menu and show tooltip text on mouse hover.
Constructor
constructor(icon)
Slider TrayIcon. Creates an instance of TrayIcon UI component.
Parameters:
| Name | Type | Description |
|---|---|---|
|
|
string |
Icon image (relative/absolute path or base64 encoded image string). |
Members
- [ readonly ] container
- [ readonly ] id
- [ readonly ] parent
- [ readonly ] screenPosition
Methods
From this class:
Inherited from UIComponent:
- contextMenu()
- destroy()
- emit()
- hide()
- icon()
- onAction()
- onDispose()
- onError()
- onMouseEvents()
- onMouseMotion()
- remove()
- text()
- tooltip()
- verifyComponent()
- visible()
Examples:
Create new TrayIcon:
const icon = new TrayIcon("/path/to/icon.png").tooltip("New App Icon").contextMenu(existing_context_menu).show();
Set an event handler:
icon.onMouseEvents(e => {
console.log(`${e.clicks} ${e.type}`);
})
.onAction(e => {
console.log("System tray icon action was performed.");
});
Show system message:
icon.showNotification(`Warning Sample`, `This is a sample message`, MessageIcon.Warning);
hide and show the icon:
icon.hide(); // or icon.visible(false);
icons.show(); // or icon.visible(true);
