Lessons · Building apps · 20 of 36
Reaching other containers
Inside names, parent.name and top-level names.
Code reaches a container by its name: title.text, score_label.color.
- Top-level containers (at the left edge of a file) can be reached by name from anywhere in the project.
- A container written inside another belongs to it. Its parent and its siblings use the plain
name; everyone else goes through the parent:
form.name_box.text. So two cards can each have their owntitlewithout a clash. - A repeated container's copies:
cell.at(1, 2),task_row.at(0).
main home:
space_inside: 24
space_between: 12
children:
form
preview
form:
space_between: 8
children:
name_box:
input: "Type a name"
save:
button: "Show it"
on_tap: preview.text = "Saved: {name_box.text}"
preview:
text: "Nothing saved yet"
text_style: 18, gray[700]
on_tap: preview.text = "Still typing: {form.name_box.text}"
Inside form, save reaches its sibling as name_box. preview is outside form, so it writes
form.name_box.
Every example here runs in Vi Studio: open it in your browser (phones too) and press Start learning on the welcome page. Each code block there has a Try it button that runs it in the phone preview.
More in Building apps
- Screensgo_to, go_back, transitions, and phone / tablet / desktop.
- Containers that take valuescard(task): one container, many values.
- Repeating thingsrepeat: task in tasks, grids, index, x, y and .at().
- Changing the screenA dot for one change, a block for several; wait and animate.
- Timers and gamesevery(), stop(), on_touch, place: x, y and on_hit.
- Sound and videoplay, loop, stop_sounds, audio and video.
- Files and projectssrc/, every file sees every name, one name in one file.
- The config blockApp name, store id, version, icon and splash screen.
- Errors and good habitsThe real error messages and their fixes; how to organise a project.
About Vi. Vi is a free, open-source programming language for building real mobile apps. You describe each screen in plain words, and Vi compiles it to React Native (Expo) for Android, iOS and the web. Its editor, Vi Studio, runs on Windows, in any browser and on your phone, with the app running live as you type. Read more about Vi.