Forms
Overview
A Form is Quorum's quickest way to build an app. It opens a window, places your controls for you, and sets up the keyboard order so that everyone can use the app. Every Form holds one or more Pages. A Page is one screen of the app, like a home screen or a settings screen. In this tutorial, you will build an app with one Page: a banner, a label, a text field and a button that greets the person who typed their name. The Pages tutorial, after Behaviors and Buttons, adds more Pages.
Goals
You have the following goals for this lesson:
By the end of this lesson, you can
- Create a Form and add controls to its main Page
- Respond to a button press with a
FormBehavior - Read what a person typed and show a result
- Choose light or dark mode and a window size
Warm up
Think of a sign-in screen or a search screen you use often. Where is each part of it: the heading, the places to type, the buttons? If you could only use the Tab key to move around it, in what order would you want to reach each part?
Vocabulary
You will be learning about the following vocabulary words:
| Term | Definition |
|---|---|
| Form | A window for an app. A Form holds one or more Pages and shows one of them at a time. |
| Page | One screen of a Form. Buttons, labels, text fields, and other controls are added to a Page. |
| Main Page | The Page a Form shows first. Every Form has one, named Main. |
| Control | A part of an interface that a person can read or use, such as a button, a label, or a text field. |
| Banner | A large heading at the top of a Page, with a title and an optional second line. |
| Label | Text on the screen that a person can read but not change. |
| Text Field | A control with one line where a person can type. |
| FormBehavior | A Behavior made for Forms. It can get the Form and the Page that is showing. |
| Focus | The control that keys go to right now. Tab moves the focus to the next control. |
| Dark Mode | A color scheme with light text on a dark background. |
New Code to Learn
You will be using the following new pieces of code:
| Quorum Code | Code Example | Explanation |
|---|---|---|
| Form NAME | Form form | Makes a new Form. It already has a main Page. |
| FORM:GetMainPage() | Page page = form:GetMainPage() | Gets the Page the Form shows first. |
| PAGE:AddBanner(TITLE, LABEL) | page:AddBanner("Greeter", "Say hello") | Adds a banner with a title and a second line of text. |
| PAGE:AddLabel(NAME, TEXT) | page:AddLabel("Greeting", "Hi!") | Adds a label. The first value is its name, the second is the text it shows. |
| PAGE:AddTextField(NAME) | page:AddTextField("Your name") | Adds a one-line text field with this name. |
| PAGE:AddButton(NAME) | page:AddButton("Say Hello") | Adds a button. Its name is also the text on it. |
| CONTROL:SetDescription(TEXT) | button:SetDescription("Shows a greeting") | Adds more detail about a control for screen readers. |
| BUTTON:SetBehavior(BEHAVIOR) | button:SetBehavior(me) | Runs the behavior's Run action when the button is pressed. |
| GetPage() | Page page = GetPage() | Inside a FormBehavior, gets the Page that is showing. |
| PAGE:GetTextField(NAME) | page:GetTextField("Your name") | Finds the text field with this name. |
| PAGE:GetLabel(NAME) | page:GetLabel("Greeting") | Finds the label with this name. |
| FIELD:GetText() | text typed = field:GetText() | Gets what was typed in a text field. |
| LABEL:SetText(TEXT) | label:SetText("Hello!") | Changes what a label shows. |
| PAGE:LeftAlignContent() | page:LeftAlignContent() | Lines the Page's controls up on the left instead of the center. |
| FORM:SetToDarkMode() | form:SetToDarkMode() | Uses light text on a dark background. |
| FORM:Display() | form:Display() | Opens the window and shows the main Page. |
| FORM:Display(WIDTH, HEIGHT) | form:Display(600, 400) | Opens a window of this size. |
CSTA Standards
This lesson covers the following CSTA K–12 standards:
For teachers · 2026 CSTA K–12 Computer Science Standards
High School · Programming
Use documentation, libraries, application programming interfaces (APIs), and other tools in program development.
Also in 5 other lessons
Middle School · Programming
Use reference documentation in program development.
Also in 2 other lessons
Middle School · Programming
Refine a computing technology based on user feedback to improve its usability and accessibility.
Also in 7 other lessons
High School · Programming
Refine a computing technology based on user feedback, testing results, and responsible design values to improve its effectiveness and impact.
Also in 4 other lessons
Explore
The Overview introduced two ways to build an interface. This tutorial covers the first: Forms. A Form does three jobs for you. It opens a window. It places each control in a row below the one before it. And it works out the keyboard order, so Tab moves through the controls from top to bottom.
Your first Form
In Quorum Studio, make a new project. Under General, choose App. Studio gives you this program:
use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page
Form form
Page page = form:GetMainPage()
page:AddButton("Hi")
form:Display()
Here is what each line does:
Form formmakes the Form. A new Form already has one Page, called the main Page.form:GetMainPage()gives you that Page, so you can add things to it.page:AddButton("Hi")adds a button. Its name, "Hi", is the text on the button. It is also what a screen reader says.form:Display()opens the window and shows the main Page.
Controls always go on a Page, not on the Form itself. Most Form programs
have these same lines: make a Form, get its main Page, add controls, and
call Display. The greeting app later in this tutorial puts the same
lines inside a class called Main, because it needs a class.
What you can put on a Page
A Page has an action for each kind of control. Each one takes a name, adds the control below the last one, and gives the control back to you, so you can change it. Each control has its own tutorial later in this series.
| Action | Adds | Tutorial |
|---|---|---|
AddBanner(title) or AddBanner(title, label) | A large heading | Groupings |
AddLabel(name) or AddLabel(name, text) | Text to read | This page |
AddButton(name) or AddButton(name, imageFile) | A button, with words or a picture | Buttons |
AddCheckbox(name) | A box that can be checked or not | Checkboxes |
AddGrouping(name) | A group of controls, such as radio buttons | Groupings, Radio Buttons |
AddTextField(name) | A one-line place to type | Text Fields |
AddTextBox(name) | A place to type many lines | Text Boxes |
AddComboBox(name) or AddComboBox(name, choices) | A text field with a list of choices that opens below it | Combo Boxes |
AddSlider(name) or AddSlider(name, minimum, maximum) | A slider for choosing a number | Sliders |
AddSliderField(name) or AddSliderField(name, minimum, maximum) | A slider with a box beside it for typing the number | Sliders |
AddProgressBar(name) or AddProgressBar(name, minimum, maximum) | A bar that shows how far along something is | Progress Bars |
AddColorWell(name) or AddColorWell(name, color) | A button showing a color, which opens a color picker | Color Wells |
AddCalendar(name) | A month to choose a day from | Calendars and Dates |
AddDateField(name) | A text field for a date, with a button that opens a calendar | Calendars and Dates |
AddList(name) | A list to pick from | Lists |
AddTree(name) | A list with items inside items | Trees |
AddSpreadsheet(name) or AddSpreadsheet(name, file) | A grid of cells, empty or from a CSV file | Spreadsheets |
AddIcon(name, imageFile) | A picture | This page |
Some controls, such as tab panes, have no Add action of their own. Later
tutorials put them on a Page with page:Add(control), and the Page lays
them out like the rest.
The name you give a control matters. You use it to find the control again later, and a screen reader uses it to tell a person what the control is. So pick names a person would understand, like "Your name", not "field1".
Building a greeting app
Now you will make an app that asks for a name and says hello. It needs to do something when the button is pressed. Code that runs when something
happens is called a behavior. For Forms, Quorum has a special behavior
class called FormBehavior. Here, the Main class itself is a FormBehavior, so it can be the button's behavior. That is what button:SetBehavior(me) means: when this button is pressed, run the Run
action in this class. The Behaviors tutorial
covers behaviors in more depth.
use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page
use Libraries.Interface.Forms.FormBehavior
use Libraries.Interface.Events.BehaviorEvent
use Libraries.Interface.Controls.Button
use Libraries.Interface.Controls.TextField
use Libraries.Game.Graphics.Label
class Main is FormBehavior
action Main
Form form
Page page = form:GetMainPage()
page:AddBanner("Greeter", "Type your name, then press Say Hello")
page:AddLabel("Name prompt", "Your name")
TextField field = page:AddTextField("Your name")
field:SetDescription("Type your first name")
Button button = page:AddButton("Say Hello")
button:SetDescription("Shows a greeting below the button")
button:SetBehavior(me)
page:AddLabel("Greeting", "No greeting yet")
form:Display()
end
action Run(BehaviorEvent event)
Page page = GetPage()
TextField field = page:GetTextField("Your name")
Label greeting = page:GetLabel("Greeting")
greeting:SetText("Hello, " + field:GetText() + "!")
end
end
Run the app. Type your name, then press Tab to move to the button and press Space or Enter. The label below the button changes to greet you.
Examine the Run action. GetPage() gives you the Page that is showing
right now. Then GetTextField("Your name") and GetLabel("Greeting") find
the controls by the names you gave them in Main. field:GetText() gives
you what the person typed, and greeting:SetText(...) changes what the
label shows.
Notice the two calls to AddLabel. The first value is the label's name, used to find it. The second value is the text it shows. The "Your name" label is there for people who can see the screen. The text
field's own name, "Your name", is what a screen reader says when the field
has the focus. SetDescription adds more detail that a screen reader can
read.
How a Page arranges controls
You never gave a position or a size in the greeting app. The Page did it. It puts each control in its own row, from top to bottom. The rows take up most of the window's width and sit in the middle. Two things are worth knowing:
- A label followed by a field share a row. When a label comes right before a text field, text box, combo box, date field, slider or progress bar, the Page puts the label beside it. In a narrow window, the label goes above the field in smaller letters instead. That is why "Your name" sits next to its text field.
- Text fields don't stretch forever. In a wide window, a text field stops growing at a comfortable width, so it doesn't run across the whole screen.
To line the controls up on the left instead of the center, call page:LeftAlignContent(). There are also CenterAlignContent() and RightAlignContent().
The order you add controls is the order they appear on the screen. It is also the order Tab moves through them. After the last control, Tab goes back to the first. Shift+Tab goes the other way. You don't write any of this yourself: the Form works out the order when the Page first appears. This keeps what a person sees and what a keyboard user reaches in the same order, which is an important part of accessible design.
Later, in the Layouts tutorial, you will learn how to place controls yourself. Until then, every tutorial uses Pages, which do this work for you.
Light mode, dark mode, and window size
A Form uses light mode unless you tell it otherwise. Call form:SetToDarkMode() before form:Display() to show light text on a dark
background. Some people find dark mode easier on their eyes. form:SetToLightMode() goes back to light mode. The Themes and Dark Mode tutorial covers this in
more depth.
form:Display() opens a window 750 pixels wide and 1000 pixels tall. To
pick another size, give the width and height: form:Display(600, 400).
use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page
Form form
form:SetToDarkMode()
Page page = form:GetMainPage()
page:AddBanner("Night Owl", "This app uses dark mode")
page:AddButton("OK")
form:Display(600, 400)
Try making the window narrower by dragging its edge while the greeting app runs. Notice the "Your name" label move from beside the field to above it.
Accessibility in Forms
Forms do much of the accessibility work for you:
- When the window opens, the first control that can take the focus gets it.
- Tab and Shift+Tab move through the controls in the order you added them.
- Titles and labels can take the focus, so a screen reader reads them as a person tabs through the Page.
- Space or Enter presses the button that has the focus.
Your job is to choose clear names, add a description when a name alone isn't enough, and add controls in an order that makes sense when read from top to bottom.
Engage
The goal of this activity is to plan a small one-page app on paper, build it as a Form, and improve it based on what someone else notices. With a partner, pick a small topic, such as a greeting card maker, a pet name picker or a "what should I read next" helper. First, sketch the Page on paper. Write next to every control the name a screen reader should say, and number the controls in the order Tab should reach them. Then build it. Your Page needs a banner, at least one label and text field pair, a button, and a label that changes when the button is pressed, based on what was typed. If you like, add one control from the table in this tutorial, such as a checkbox or a slider field.
When your app works, swap with another pair. Test their app using only the keyboard: unplug the mouse or keep your hand off it. Then try it in a narrow window and in dark mode. Write down which design choices made the app easy to use, which were missing, and one change that would help most. Give them your notes, and use the notes you get back to make one change to your own app. Run it again to check the change helped.
Wrap up
A Form decides where controls go and what order the keyboard reaches them in. What do you gain when a library makes these choices for you? What might you give up? Think of an app where you would want more control than a Form gives you.