Elements
The six kinds of elements, their fields and defaults, screens and tabs.
An element is a clickable rectangle of the widget. Its rectangle is in widget units, from the top-left corner of the widget, exactly as in the WBP Designer.
Elements come from a layout component (written by the online editor) and from the
Elements list of interactive_widget_component. Both can be used together.
Kinds
| Kind | Behaviour |
|---|---|
Button | A click. |
Toggle | A click switches it On or Off. |
Choice | Exclusive in its Group, like radio buttons. Clicking a selected choice keeps it selected. |
Tab | A choice that also opens the screen OpensScreen. |
Slider | A value from MinValue to MaxValue along its rectangle, snapped to Step. |
Stepper | Moves the slider named Target by Steps steps. |
Fields
Every field has a default value: a layout only writes the fields you changed.
| Field | Default | For | Meaning |
|---|---|---|---|
Name | "Button" | all | Unique name of the element in the widget. Events and WBP fields use it: write it as a Verse identifier (letters, digits and _, not starting with a digit). |
Kind | Button | all | One of the six kinds. |
X, Y | 0.0 | all | Top-left corner, in widget units. |
Width, Height | 200.0, 80.0 | all | Size, in widget units. |
Prompt | "" | all | Text of the interact prompt (E, mobile, controller). Empty: the name. |
StartEnabled | true | all | A disabled element can be aimed at but not clicked. |
Screen | 0 | all | Screen the element lives on. 0: every screen. |
Cooldown | 0.0 | all | Seconds before the same player can click it again. |
StartOn | false | Toggle, Choice, Tab | Starts On, or selected. |
Group | "" | Choice, Tab | Choices and tabs with the same group are exclusive. |
OpensScreen | 0 | Tab | Screen opened by the tab. |
MinValue, MaxValue | 0.0, 1.0 | Slider | Value at the left (or bottom) end and at the right (or top) end. |
Step | 0.0 | Slider | Values snap to multiples of Step from MinValue. 0: continuous. |
StartValue | 0.0 | Slider | Value when the game starts. |
Vertical | false | Slider | Runs from the bottom (MinValue) to the top (MaxValue). |
Target | "" | Stepper | Name of the slider it moves. |
Steps | 1 | Stepper | Steps per click. Negative goes towards MinValue. |
OnClick, WhenOn, WhenOff | empty | all | Trigger devices. See No-code actions. |
Choices and groups
Choices with the same Group form a group: selecting one deselects the others. An empty Group gathers all the
choices without a group into one group, and all the tabs without a group into another.
If several choices of a group have StartOn, the first one starts selected.
Screens and tabs
A widget can have several screens, like the pages of a menu. Only the elements of the active screen, and those with
Screen set to 0, can be aimed at.
- A
TabwithOpensScreenset to2opens screen 2 when it is clicked, and becomes the selected tab of its group. - The game starts on the screen of the tab with
StartOn, else of the first tab, else on the lowestScreenused. - Your WBP shows the active screen through a
Screenfield (int) bound to the Active Widget Index of a WidgetSwitcher. The editor writes it when you tick Screen field. Screen 1 is index 1: leave index 0 empty, or make it a screen of its own. - From Verse,
SetScreenandGetScreenchange and read the screen.
Sliders
- Firing on a slider sets the value under the crosshair. Holding fire drags it: the value follows the crosshair, and the click is sent when fire is released.
- E, or the interact button, sets the value under the crosshair. Used without aiming at the slider (from a
mobile prompt), it moves the slider one step up, and back to
MinValueafterMaxValue. - One step is
Step, or a tenth of the range whenStepis0. - The value shown to players (the
Textfield) is a whole number whenStepis 1 or more, else it has two decimals.
Steppers
A stepper moves its Target slider by Steps steps per click (-1 goes down). While its slider is disabled, the
slider does not move. In Verse, the click names the stepper, and the change names the slider: see
Verse API.
Writing elements by hand
In the Details panel, add entries to Elements on interactive_widget_component and fill their fields. Or write a
layout component yourself:
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
using { WorldUIKit }
my_panel_layout<public> := class<final_super>(component, interactive_layout):
GetLayout<override>()<transacts>:interactive_layout_data =
interactive_layout_data{Width := 1200.0, Height := 800.0, Elements := array{
interactive_element{Name := "Buy", Kind := interactive_kind.Button, X := 40.0, Y := 600.0, Width := 300.0, Height := 90.0, Prompt := "Buy"},
interactive_element{Name := "Music", Kind := interactive_kind.Toggle, X := 40.0, Y := 100.0, Width := 300.0, Height := 60.0, StartOn := true}}}When WidgetWidth and WidgetHeight are 0, the widget size comes from the layout; without a layout, from the
elements (their bounding box plus 40 units).
Elements written by hand are clickable, but they write no field: your widget shows no hover and no state. To show
them, generate the layout with the online editor, or implement interactive_fields in
your layout component (Verse API).