Screen
Creating and Managing Widgets
Objective: Create and manipulate widgets to build user interfaces.
- Create a new widget:
scr new "myButton" "button" "0" "max/min" "root";
- "myButton" is the widget identifier.
- "button" is the widget type.
- "0" is the weight.
- "max/min" is the size.
- "root" is the parent widget.
- Set a property:
scr set "myButton" "title" "Click Me";
- "myButton" is the widget identifier.
- "title" is the property.
- "Click Me" is the value.
- Get a property:
scr get "myButton" "title" buttonTitle; csl write buttonTitle;
Practical Example
Objective: Create an input field and retrieve its value.
- Create an input field:
scr new "myInput" "input" "0" "max/min" "root"; scr set "myInput" "value" "Enter text";
- Get and display the input value:
scr get "myInput" "value" inputValue; csl write inputValue;
Tips
- Use unique widget identifiers to avoid conflicts.
- Manage widget hierarchy with parent-child relationships.
- Clear or delete unused widgets to optimize performance.
Conclusion
Screen commands like scr new, scr set, and scr get allow you to create and manage dynamic user interfaces in Virtel Steps.
Supported Widget Types in Virtel Steps
In Virtel Steps, various widget types are available for creating user interfaces. Each type has its own purpose and set of properties that can be configured using the commands scr new and scr set. Below is a list of all supported widget types with descriptions and examples.
1. VIEW
A basic container that can hold other widgets. It is used as a foundation for more complex structures.
2. TEXT
A widget for displaying text content. It supports different styles through the variant property (e.g., "super", "primary", "secondary", "tertiary").
3. BUTTON
An interactive widget that responds to clicks. It can contain text or other widgets and supports styles like "primary" and "secondary".
4. INPUT
A field for user text input. It can have a label and store the entered value.
5. COLUMN
A container that arranges child widgets vertically. It supports scrolling and alignment.
6. ROW
A container that arranges child widgets horizontally. It supports scrolling and alignment.
7. ADAPTIVE
An adaptive container that automatically adjusts the layout of child widgets based on available space (horizontally or vertically).
8. CARD
A container with rounded corners and a background color, often used to group related elements.
9. IMAGE
A widget for displaying images. It can load images from a local file or URL.
10. TOP_BAR
A top bar typically used for headers, navigation buttons, or other controls.
11. BOTTOM_BAR
A bottom bar often containing navigation buttons or actions, such as a FAB (Floating Action Button).
12. LIST
A widget for displaying lists of items, supporting scrolling and configurable for vertical or horizontal layout.
Widget Properties
Each widget supports a set of properties that can be configured using the scr set command. Here are the main properties available for most widgets:
- weight — The widget's weight for space distribution in a container.
- variant — The widget's style (e.g., "primary", "secondary").
- title — The text label or title.
- value — The value stored by the widget (e.g., text in an input field).
- foreground — The foreground color or icon.
- background — The background color.
- onClick — The path to a
.stepsfile to run when clicked. - paddingTop, paddingRight, paddingBottom, paddingLeft — Internal padding.
- marginTop, marginRight, marginBottom, marginLeft — External margins.
- scrollable — Enables scrolling for containers.
- size — The widget's size (e.g., "max/min", "100/50").
- align — Alignment of child elements (e.g., "center", "start", "end").
- justify — Space distribution between child elements (e.g., "spaceBetween", "spaceAround").
Practical Example
Creating a screen with navigation and a form:
- Create the main container:
scr new "screen" "column" "0" "max/max" "root";
- Add the top bar:
scr new "topBar" "topBar" "0" "max/min" "screen"; scr set "topBar" "background" "gray";
- Add a settings button to the top bar:
scr new "settingsBtn" "button" "0" "min/min" "topBar"; scr set "settingsBtn" "title" "Settings"; scr set "settingsBtn" "onClick" "/settings.steps";
- Add the main content:
scr new "content" "column" "1" "max/max" "screen"; scr set "content" "padding" "15";
- Add an input field:
scr new "nameInput" "input" "0" "max/min" "content"; scr set "nameInput" "title" "Your Name";
- Add a submit button:
scr new "submitBtn" "button" "0" "min/min" "content"; scr set "submitBtn" "title" "Submit"; scr set "submitBtn" "onClick" "/submit.steps";
Tips
- Each widget must have a unique name (
idName) to avoid conflicts. - Use containers (
column,row,adaptive) to organize widgets. - Configure
variant,foreground, andbackgroundto match the design. - Use
onClickto bind actions to widgets. - Enable
scrollableonly for containers with a lot of content.
Conclusion
The supported widget types in Virtel Steps provide extensive capabilities for creating complex and adaptive user interfaces. From basic text and button widgets to containers and navigation bars, each widget type has its purpose and set of properties, allowing flexible customization of the appearance and behavior of applications.
Commands
Creates a new widget on the screen with a specified type, weight, size, and parent widget.
idName: The unique identifier of the widget (type: VAR).viewType: The type of widget ("view", "text", "button", "input", etc.) (type: VAR).weight: The weight for space distribution (number, 0 if none) (type: VAR).size: The size in "width/height" format (e.g., "max/min") (type: VAR).parent: The identifier of the parent widget (type: VAR).
This example creates a button "myButton" in "root" and sets its title to "Click Me".
Pauses a widget, stopping its updates.
idName: The identifier of the widget to pause (type: VAR).
This example creates a button and pauses it.
Resumes a paused widget.
idName: The identifier of the widget to resume (type: VAR).
This example creates a button, pauses it, and then resumes it.
Clears all child widgets from a specified widget, removing them recursively.
idName: The identifier of the widget to clear (type: VAR).
This example creates a container with a child text widget and then clears the container.
Deletes a widget from the system.
idName: The identifier of the widget to delete (type: VAR).
This example creates a button and then deletes it.
Sets a property of a widget by its identifier.
idName: The identifier of the widget (type: VAR).property: The property to set (e.g., "title", "onClick", "weight") (type: VAR).value: The value for the property (type: VAR).
This example creates a button and sets its title to "Click Me".
Gets the value of a widget’s property and stores it in a new variable.
idName: The identifier of the widget (type: VAR).property: The property to get (type: VAR).newVarName: The name of the new variable to store the value (type: VAR).
This example sets an input value to "Hello", retrieves it, and prints it.
Sets up navigation for system buttons (settings, home, back) by assigning a file to run when clicked.
file: The path to the file to run (type: VAR).navName: The navigation button name ("settings", "home", "back") (type: VAR).
This example assigns "/settings.steps" to the "settings" navigation button.
Creates a new page in the system for displaying widgets.
This example creates a new page and adds a title widget to it.