tray

hxcpp externs for webview/tray to create a system tray icon with a popup menu, for Windows, MacOS and Linux, for usage in Haxe applications and services with ease.
https://github.com/Davvex87/tray

To install, run:

haxelib install tray 0.1.0 

See using Haxelib in Haxelib documentation for more information.

README.md

tray

hxcpp externs for webview/tray to create a system tray icon with a popup menu, for Windows, MacOS and Linux, for usage in Haxe applications and services with ease.

Usage

import tray.Tray;
import tray.TrayMenuDef;
import tray.TrayMenuItem;

class Main
{
    static function main()
    {

        function subItemCb(item:TrayMenuItem)
            trace(item.text);

        var tray = new Tray("icon.ico",
        [
            TrayButton("Hello", item -> {
                item.text = "Hi again";   // items are mutable, change me!
                Tray.current.update();
            }),

            TrayToggle("Enabled", true, item -> trace('enabled = ${item.checked}')),

            TraySubmenu("More", [
                TrayButton("Sub item A", subItemCb),
                TrayButton("Sub item B", subItemCb),
            ]),

            TraySeparator,

            TrayButton("Quit", _ -> Tray.current.exit()),
        ]);

        if (!tray.init()) throw "tray init failed";
        tray.run();
        // code down here still runs, the process only dies once the tray exits,
        // unless you pass `true` as the first argument to `tray.run()`

    }
}

Items

TrayButton(text:String, onClick:TrayMenuItem->Void, ?disabled:Bool);
TrayToggle(text:String, checked:Bool, ?onChange:TrayMenuItem->Void, ?disabled:Bool);
TraySubmenu(text:String, items:Array<TrayMenuDef>, ?disabled:Bool);
TraySeparator;

License

webview/tray is licensed under MIT.

These hxcpp externs are under MIT too.

Contributors
Davvex87
Version
0.1.0
Published
8 weeks ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub