// Button is a clickable button that performs some task.
typeButtoninterface{
Control
// OnClicked sets the event handler for when the Button is clicked.
OnClicked(func())
// Text and SetText get and set the Button's label text.
Text()string
SetText(textstring)
}
// NewButton creates a new Button with the given label text.
funcNewButton(textstring)Button{
returnnewButton(text)
}
// Checkbox is a clickable box that indicates some Boolean value.
typeCheckboxinterface{
Control
// OnToggled sets the event handler for when the Checkbox is toggled.
OnToggled(func())
// Text and SetText get and set the Checkbox's label text.
Text()string
SetText(textstring)
// Checked and SetChecked get and set the Checkbox's check state.
Checked()bool
SetChecked(checkedbool)
}
// NewCheckbox creates a new Checkbox with the given label text.
// The Checkbox will be initially unchecked.
funcNewCheckbox(textstring)Checkbox{
returnnewCheckbox(text)
}
// TextField is a Control in which the user can enter a single line of text.
typeTextFieldinterface{
Control
// Text and SetText are Requests that get and set the TextField's text.
Text()string
SetText(textstring)
// OnChanged is triggered when the text in a TextField is changed somehow.
// Do not bother trying to figure out how the text was changed; instead, perform your validation and use Invalid to inform the user that the entered text is invalid instead.
OnChanged(func())
// Invalid throws a non-modal alert (whose nature is system-defined) on or near the TextField that alerts the user that input is invalid.
// The string passed to Invalid will be displayed to the user to inform them of what specifically is wrong with the input.
// Pass an empty string to remove the warning.
Invalid(reasonstring)
}
// NewTextField creates a new TextField.
funcNewTextField()TextField{
returnnewTextField()
}
// NewPasswordField creates a new TextField for entering passwords; that is, it hides the text being entered.
funcNewPasswordField()TextField{
returnnewPasswordField()
}
// Tab is a Control that contains multiple pages of tabs, each containing a single Control.
// You can add and remove tabs from the Tab at any time.
// The appearance of a Tab with no tabs is implementation-defined.
typeTabinterface{
Control
// Append adds a new tab to Tab.
// The tab is added to the end of the current list of tabs.
Append(namestring,controlControl)
}
// NewTab creates a new Tab with no tabs.
funcNewTab()Tab{
returnnewTab()
}
// Label is a Control that shows a static line of text.
// Label shows one line of text; any text that does not fit is truncated.
// Labels are left-aligned. [FUTURE PLANS: For platform-specific horizontal alignment rules, use a Form.]
typeLabelinterface{
Control
// Text and SetText get and set the Label's text.
Text()string
SetText(textstring)
}
// NewLabel creates a new Label with the given text.
funcNewLabel(textstring)Label{
returnnewLabel(text)
}
// Group is a Control that holds a single Control; if that Control also contains other Controls, then the Controls will appear visually grouped together.
// The appearance of a Group varies from system to system; for the most part a Group consists of a thin frame.
// All Groups have a text label indicating what the Group is for.
typeGroupinterface{
Control
// Text and SetText get and set the Group's label text.