Skip to content

Search documentation

Enter at least two characters.

    TrayService

    SDK 0.1.0-preview.1 · ExperimentalDownload & release notes ↗

    Host-installed system-tray integration. Keep platform availability and handle lifetime in mind.

    Advanced app/host integration API. Useful for lower-level work; ordinary app authors can start with the app-building path. This is public API, not permission to access private toolkit objects.

    Tray and the supplied Windows shell adapter. GTK reports unsupported.

    The host is the program running your Luau code: normally the SDK’s native runner. Its provider/adapter implements an optional service. You do not need to write one to use a service already supplied by the SDK. Capabilities explains the manifest and remaining platform limits.

    Advanced Windows host protocol; GTK reports unsupported. A tooltip is 1–127 UTF-8 bytes. A watch is separate from icon creation.

    Where to put it: replace Src/Main.luau in a project created with this SDK. This is the complete entry file.

    Project setup: add Tray to Capabilities in lui.json. See the capability guide.

    local Window = Instance.new("Window", {
    Title = "LUI example", Size = UDim2.fromOffset(560, 280),
    })
    local Status = Instance.new("TextLabel", {
    Parent = Window, Text = "Ready", Position = UDim2.fromOffset(16, 170),
    Size = UDim2.new(1, -32, 0, 72),
    })
    local Button = Instance.new("TextButton", {
    Parent = Window, Text = "Try it", Size = UDim2.fromOffset(220, 44),
    Position = UDim2.fromOffset(16, 16),
    })
    Button.Text = "Create tray icon"
    Button.Activated:Connect(function()
    local Tray = app:GetService("TrayService")
    Tray:Create(buffer.fromstring("LUI example"), nil, function(_, Handle, Failure)
    if Failure or not Handle then Status.Text = "Tray unavailable"; return end
    Status.Text = "Icon created for five seconds"
    task.delay(5, function() Handle:Close() end)
    end)
    end)
    Window.Visible = true

    Expected result: On the supported Windows shell, pressing the button creates a temporary tray icon and closes its handle five seconds later.

    • This is an advanced public host protocol. The selected Windows shell has an adapter; GTK reports unsupported.
    • Keep the icon handle and request alive while needed. Close/cancel them at shutdown; creating an icon is not an ordinary visual Instance.

    Creates a tray icon using a UTF-8 tooltip buffer and nil handle. Completion returns an owned NativeHandle. Close that handle to remove the icon.

    Create(Input: buffer, Handle: NativeHandle?, Complete: (buffer?, NativeHandle?, string?) -> (), Progress: ((buffer) -> ())?) -> NativeRequest

    Watches an icon handle using an empty input buffer. Activation arrives through the progress callback; the watch expires after at most five minutes and must be rearmed deliberately.

    Watch(Input: buffer, Handle: NativeHandle?, Complete: (buffer?, NativeHandle?, string?) -> (), Progress: ((buffer) -> ())?) -> NativeRequest
    Full type declaration — for type checking and deeper reference

    The declaration is generated from the SDK. Self is supplied by a colon call; read means the field cannot be assigned. See how to read this reference.

    export type TrayService = {
    read Create: (Self: TrayService, Input: buffer, Handle: NativeHandle?, Complete: (buffer?, NativeHandle?, string?) -> (), Progress: ((buffer) -> ())?) -> NativeRequest,
    read Watch: (Self: TrayService, Input: buffer, Handle: NativeHandle?, Complete: (buffer?, NativeHandle?, string?) -> (), Progress: ((buffer) -> ())?) -> NativeRequest,
    }

    See platform limits before relying on host-specific behavior. The framework design specification and reflection/type sources are deeper engineering references, not extra setup required to build an app.