Object reference

UI

The UI object, its operations, examples and notes.

Object description

Provides the native user-interface API shared by ZPE and ZPEX. It creates windows, controls, layouts, menus, dialogs, charts, browser views, video views, and other native UI elements through the platform UI bridge.

Creating a window

Create a UI object, create a window, add controls, and then show the window. UI methods return native UI objects that can be configured with their own methods.

YASS
$ui = new UI()
$window = $ui->window("Example", 480, 320)
$button = $window->button("Continue")
$button->on(UI::Button::Action.click, () => $window->close())
$window->show()

UI functions

The top-level UI object provides availability and display helpers, including available(), is_dark_mode_enabled(), window(), screen_screenshot(), set_icon(), use_native(), browser(), video(), run(), and stop().

Windows, controls, and layouts

Windows support buttons, labels, images, browser and video controls, text fields, checkboxes, text areas, sliders, progress bars, separators, lists, spreadsheets, toggles, tab containers, charts, turtles, menus, dialogs, and file or directory choosers. Layout helpers include vertical, horizontal, grid, and constraint layouts.

Common control methods include enabled(), set_enabled(), visible(), set_visible(), focus(), set_tooltip(), style(), and set_fill(). Specific controls expose their own value, text, selection, media, chart, or menu operations.

Events and enumerations

Controls accept callbacks through on(). Use the static UI event values to avoid relying on literal strings.

YASS
$slider->on(UI::Slider::Action.change, &slider_changed)
$button->on(UI::Button::Action.mouseover, &button_hovered)

Object functions

Inner objects