SsimnJS Docs

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

KindBehaviour
ButtonA click.
ToggleA click switches it On or Off.
ChoiceExclusive in its Group, like radio buttons. Clicking a selected choice keeps it selected.
TabA choice that also opens the screen OpensScreen.
SliderA value from MinValue to MaxValue along its rectangle, snapped to Step.
StepperMoves the slider named Target by Steps steps.

Fields

Every field has a default value: a layout only writes the fields you changed.

FieldDefaultForMeaning
Name"Button"allUnique 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).
KindButtonallOne of the six kinds.
X, Y0.0allTop-left corner, in widget units.
Width, Height200.0, 80.0allSize, in widget units.
Prompt""allText of the interact prompt (E, mobile, controller). Empty: the name.
StartEnabledtrueallA disabled element can be aimed at but not clicked.
Screen0allScreen the element lives on. 0: every screen.
Cooldown0.0allSeconds before the same player can click it again.
StartOnfalseToggle, Choice, TabStarts On, or selected.
Group""Choice, TabChoices and tabs with the same group are exclusive.
OpensScreen0TabScreen opened by the tab.
MinValue, MaxValue0.0, 1.0SliderValue at the left (or bottom) end and at the right (or top) end.
Step0.0SliderValues snap to multiples of Step from MinValue. 0: continuous.
StartValue0.0SliderValue when the game starts.
VerticalfalseSliderRuns from the bottom (MinValue) to the top (MaxValue).
Target""StepperName of the slider it moves.
Steps1StepperSteps per click. Negative goes towards MinValue.
OnClick, WhenOn, WhenOffemptyallTrigger 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 Tab with OpensScreen set to 2 opens 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 lowest Screen used.
  • Your WBP shows the active screen through a Screen field (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, SetScreen and GetScreen change 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 MinValue after MaxValue.
  • One step is Step, or a tenth of the range when Step is 0.
  • The value shown to players (the Text field) is a whole number when Step is 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:

my_panel_layout.verse
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).

On this page