Tray

Neutralino's OS API (setTray method): https://neutralino.js.org/docs/api/os#ossettrayoptions

TrayItem object

Property
Type
Description

text

string

Item text

id

string

Item id

disabled

boolean

Is item disabled (true for text, false for buttons)

checked

boolean

Is item checked (true for checkboxes, false for other)

click

(item: TrayItem) => void

Event that will be called when the item will be clicked

Tray object

constructor(icon, items)

import { Tray } from '@empathize/framework';

const tray = new Tray('path_to/my_icon.png', [
    { text: 'Example text', disabled: true },
    {
        text: 'Example button',
        click: (item) => {
            console.log(`Hey! You just clicked "${item.text}"!`);
        }
    }
]);

tray.items

List tray items

import { Tray } from '@empathize/framework';

const tray = new Tray('path_to/my_icon.png', [
    { text: 'Example text 1', disabled: true },
    { text: 'Example text 2', disabled: true }
]);

for (const item of tray.items)
    console.log(item.text);

Specify tray items

import { Tray } from '@empathize/framework';

const tray = new Tray('path_to/my_icon.png');

tray.items = [
    { text: 'Example text 1', disabled: true },
    { text: 'Example text 2', disabled: true }
];

tray.update(items)

import { Tray } from '@empathize/framework';

const tray = new Tray('path_to/my_icon.png', [
    { text: 'Example text', disabled: true }
]);

// Update already existing tray
tray.update();

// Specify new items and update already existing tray
tray.update([
    { text: 'Updated example text', disabled: true }
]);

tray.hide()

import { Tray } from '@empathize/framework';

const tray = new Tray('path_to/my_icon.png', [
    { text: 'Example text', disabled: true }
]);

// Hide tray items (tray itself can't be hidden while application is running)
tray.hide();

Last updated