Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

Official ZPE/YASS documentationUI

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()
$window->run()

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(), set_fill(), and cursor(). Specific controls expose their own value, text, selection, media, chart, or menu operations. Buttons use the pointer cursor by default.

Pages and media backgrounds (ZPE 1.14.11+)

A single native window can host multiple UIPage objects. Create a page with $window->page() and display it with $window->set_page($page). Controls belong to their page and are shown or hidden together, so page changes do not create additional operating-system windows.

Pages support mutually exclusive background images, videos and colours. Background videos fill the page, loop, remain muted and stop when another page becomes active. A window may also own background audio through background_audio(); it follows application focus and can be removed by passing null.

YASS
$home = $window->page()
$home->background_video("background.mp4")
$home->button("Open library")
$window->set_page($home)

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)

Use UI::CursorType.POINTER, UI::CursorType.DEFAULT or UI::CursorType.IBEAM with a control's cursor() method.

Object functions

Inner objects

Comments

There are no comments on this page.

New comment

Comments are welcome and encouraged, including disagreement and critique. However, this is not a space for abuse. Disagreement is welcome; personal attacks, harassment, or hate will be removed instantly. This site reflects personal opinions, not universal truths. If you can’t distinguish between the two, this probably isn’t the place for you. The system temporarily stores IP addresses and browser user agents for the purposes of spam prevention, moderation, and safeguarding. This data is automatically removed after fourteen days. Your email address is stored so that replies can be sent to your email address.

Comments powered by BalfComment

Feedback 👍
Comments are sent via email to me.