Cross-platform native tray helpers for MoonBit.
guard @tray.is_supported() else {
return
}
let tray = @tray.create(
identifier="com.example.demo",
tooltip="MoonBit tray demo",
)
match tray {
Ok(tray) => {
match tray.show() {
Ok(_) =>
match tray.pump() {
Ok(_) => ()
Err(error) => println(error)
}
Err(error) => println(error)
}
tray.destroy()
}
Err(error) => println(error)
}pub struct Tray {
handle : Int64
native : Bool
platform : Platform
identifier : String
icon : String?
tooltip : String
visible : Bool
destroyed : Bool
}let tray = @tray.create(icon=Some("/path/to/icon.png"), tooltip="My App").unwrap()
let _ = tray.show()
// ... run the application event loop, calling `tray.pump()` as needed ...
tray.destroy()fn default_identifier() -> Stringfn ensure_supported() -> Result[Unit, String]fn is_supported() -> Booltest "is_supported probes capability without creating a tray" {
let _ : Bool = is_supported()
}Cross-platform native tray helpers for MoonBit.