Documentation
¶
Index ¶
- func AutoComplete(c *ui.Context, value *string, p AutoCompleteProps) ui.Element
- func Calendar(c *ui.Context, value *time.Time, p CalendarProps) ui.Element
- func ComboBox(c *ui.Context, value *string, p ComboBoxProps) ui.Element
- func DatePicker(c *ui.Context, value *time.Time, p DatePickerProps) ui.Element
- func DateRangePicker(c *ui.Context, value *DateRange, p DatePickerProps) ui.Element
- func EditableText(c *ui.Context, value *string, editing *bool, p EditableTextProps) ui.Element
- func HotkeyInput(c *ui.Context, value *string, p HotkeyInputProps) ui.Element
- func ImageWell(c *ui.Context, value *ImageWellValue, p ImageWellProps) ui.Element
- func Input(c *ui.Context, value *string, p InputProps) ui.Element
- func InputNumber(c *ui.Context, value *float64, p InputNumberProps) ui.Element
- func InputOTP(c *ui.Context, value *string, p InputOTPProps) ui.Element
- func InputPassword(c *ui.Context, value *string, p InputProps) ui.Element
- func RichTextEditor(c *ui.Context, doc *richtext.Document, p RichTextEditorProps) ui.Element
- func RuleEditor(c *ui.Context, set *RuleSet, p RuleEditorProps) ui.Element
- func SearchBar(c *ui.Context, query *string, p SearchBarProps) ui.Element
- func Select(c *ui.Context, selected *string, p SelectProps) ui.Element
- func Stepper(c *ui.Context, value *float64, p StepperProps) ui.Element
- func TextArea(c *ui.Context, value *string, p TextAreaProps) ui.Element
- func TimePicker(c *ui.Context, value *TimeOfDay, p TimePickerProps) ui.Element
- func TokenField(c *ui.Context, tokens *[]string, p TokenFieldProps) ui.Element
- func Upload(c *ui.Context, p UploadProps, content func()) ui.Element
- type AutoCompleteOption
- type AutoCompleteProps
- type CalendarProps
- type ComboBoxProps
- type DatePickerProps
- type DateRange
- type EditableTextProps
- type File
- type HotkeyInputProps
- type ImageWellProps
- type ImageWellValue
- type InputNumberProps
- type InputOTPProps
- type InputProps
- type InputVariant
- type PickOptions
- type RichTextEditorProps
- type Rule
- type RuleEditorProps
- type RuleField
- type RuleOperator
- type RuleSet
- type SearchBarProps
- type SelectOption
- type SelectProps
- type StepperProps
- type TextAreaProps
- type TimeOfDay
- type TimePickerProps
- type TokenFieldProps
- type UploadProps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoComplete ¶
AutoComplete is an Input that suggests p.Options below it as the user types, matching what was typed, and writes the one chosen into *value. It returns the text input.
func Calendar ¶
Calendar chooses a day into *value from a month of days, with buttons that turn the months and years and views to choose a month and a year. The arrows, Page Up and Page Down move between days while a day has the focus, and Enter chooses one.
func ComboBox ¶
ComboBox edits value directly and offers a list of choices. Its arrow opens the complete list, and typing filters it. Text typed or chosen is kept as the value.
func DatePicker ¶
DatePicker chooses a day into *value, the zero time while none is chosen, from a Calendar that opens below its trigger and closes once a day is chosen. It returns the trigger.
func DateRangePicker ¶
DateRangePicker chooses a start and an end day using the same calendar as DatePicker. Choosing an earlier second endpoint arranges the two days in chronological order.
func EditableText ¶
EditableText shows *value as text with an edit button; while *editing it is a field holding a draft, which Enter or the save button writes to *value and Escape drops. A changed draft shows buttons to reset and save it.
func HotkeyInput ¶
HotkeyInput records a keyboard shortcut into *value, written as display.Hotkey takes it: focus it and press the keys. A shortcut needs a modifier and one other key, and may not be one of p.Conflicts. It returns the focusable control.
func ImageWell ¶
func ImageWell(c *ui.Context, value *ImageWellValue, p ImageWellProps) ui.Element
ImageWell accepts an image by drop or from a file picker, previews it and lets people clear it. A failed decode leaves the existing image displayed.
func InputNumber ¶
InputNumber edits *value as a number: typed text takes effect on Enter or when the field loses the focus, clamped to the bounds, and the arrows at the end, Up and Down step it. It returns the text input.
func InputOTP ¶
InputOTP edits a one-time code in a row of cells, one character each, which typing fills from the first and Backspace empties from the last. It returns the text input behind the cells.
func InputPassword ¶
InputPassword is an Input that hides what it holds, with an eye button at the end that shows it. It returns the text input.
func RichTextEditor ¶
RichTextEditor edits a MyGo rich text document with a formatting toolbar. Keep the document for the lifetime of the editing session.
func RuleEditor ¶
RuleEditor builds rows of attribute, operator and value fields, with add and remove actions and a choice between matching all or any of the rules.
func SearchBar ¶
SearchBar is an Input for a search query: a search icon before it, a button clearing the query, and an optional window-wide shortcut that focuses it. It returns the text input.
func Select ¶
Select chooses one of p.Options into *selected from a popup below its trigger. The arrows open it and move among the options, Enter or Space chooses one and Escape closes it. It returns the trigger.
func Stepper ¶
Stepper changes a number with a pair of arrows, independently of a text field. The arrow keys work while the stepper has focus.
func TimePicker ¶
TimePicker edits hours, minutes and optionally seconds. The stored hour is always on a 24-hour clock, including when the display uses AM and PM.
func TokenField ¶
TokenField edits a list of strings. Enter or comma accepts an entry and Backspace on an empty input removes its last token. Each chip has its own remove button.
Types ¶
type AutoCompleteOption ¶
type AutoCompleteProps ¶
type AutoCompleteProps struct {
// Options are the suggestions; those whose value or label holds what was typed show.
Options []AutoCompleteOption
// EmptyText shows in the popup when no option matches; the popup closes without it.
EmptyText string
// Placeholder shows while the field is empty.
Placeholder string
// Prefix shows an icon before the text.
Prefix *ui.SVG
// Variant picks the surface, as Input's.
Variant InputVariant
// Size sets the height (24, 32 or 40), padding and font size, as Input's.
Size theme.Size
}
type CalendarProps ¶
type ComboBoxProps ¶
type ComboBoxProps struct {
// Label is the accessible name of the text field.
Label string
// Options are distinct strings that can be chosen from the popup.
Options []string
// Placeholder appears while the field is empty.
Placeholder string
// Size and Variant set the field's height and surface.
Size theme.Size
Variant InputVariant
// Disabled prevents typing and opening the options.
Disabled bool
}
type DatePickerProps ¶
type DatePickerProps struct {
// Placeholder shows while no day is chosen: "Select date" when empty.
Placeholder string
// Format writes the chosen day in the trigger, as time.Format takes it: "2006-01-02" when
// empty.
Format string
// AllowClear adds a button that empties the value.
AllowClear bool
// DisabledDate reports the days that cannot be chosen, as the Calendar's.
DisabledDate func(day time.Time) bool
// WeekStart is the first day of each week: Sunday when zero.
WeekStart time.Weekday
// NoToday hides the calendar's Today button.
NoToday bool
// Variant picks the trigger's surface, as Input's.
Variant InputVariant
// Size sets the trigger's height (24, 32 or 40), padding and font size, as Input's.
Size theme.Size
// Disabled keeps the picker from opening.
Disabled bool
}
type DateRange ¶
DateRange stores the endpoints of a date range. End is zero while an endpoint is pending.
type EditableTextProps ¶
type EditableTextProps struct {
// NoEditIcon hides the edit button beside the text; editing then starts by setting *editing.
NoEditIcon bool
// Variant picks the editing field's surface, as Input's.
Variant InputVariant
// Size sets the height (24, 32 or 40), as Input's.
Size theme.Size
// OnChangeEnd runs with the new text when an edit is saved.
OnChangeEnd func(text string)
}
type File ¶
type File struct {
// Name is the file's name, without its folder.
Name string
// Path is where the file is, empty for a file picked in a browser, which has no path: Data
// holds it then.
Path string
// Type is the file's media type, as "image/png", guessed from its extension; empty when
// unknown.
Type string
// Size is the file's length in bytes.
Size int64
// Data is the content of a file without a Path.
Data []byte
}
File is a file picked or dropped on an Upload.
func PickFiles ¶
func PickFiles(o PickOptions) ([]File, error)
PickFiles shows the system's open dialog for o and returns the files chosen, nil when canceled. It blocks until the dialog closes.
type HotkeyInputProps ¶
type HotkeyInputProps struct {
// Placeholder shows while no shortcut is set: "Press keys to record shortcut" when empty.
Placeholder string
// ResetValue is the default shortcut; a reset button brings it back while the value differs.
ResetValue string
// AllowClear adds a button that removes the shortcut.
AllowClear bool
// Conflicts are shortcuts taken elsewhere, which recording refuses.
Conflicts []string
// OnConflict runs with a refused shortcut.
OnConflict func(keys string)
// Platform names the keys and picks what mod means, as display.HotkeyProps's.
Platform display.HotkeyPlatform
// Variant picks the surface, as Input's.
Variant InputVariant
// Disabled keeps the shortcut from changing.
Disabled bool
}
type ImageWellProps ¶
type ImageWellProps struct {
// Label names the image well and the selection button.
Label string
// Width and Height size the preview, defaulting to 210 by 132 DIPs.
Width, Height float32
// Disabled prevents replacing or removing the displayed image.
Disabled bool
// Picker is an optional replacement for the system or browser file chooser.
Picker func(PickOptions) ([]File, error)
}
type ImageWellValue ¶
type ImageWellValue struct {
Image ui.ImageSource
File File
}
ImageWellValue holds the displayed image and the file it was picked from, if any.
type InputNumberProps ¶
type InputNumberProps struct {
// Min and Max bound the value; equal, as both zero, they leave it unbounded.
Min, Max float64
// Step is how far the arrows, Up and Down move the value: 1 when zero.
Step float64
// Precision fixes the digits shown after the point. A bound with more digits is shown
// exactly. With 0, the field shows as many digits as the value has.
Precision int
// NoControls hides the up and down arrows at the end.
NoControls bool
// Placeholder shows while the field is empty.
Placeholder string
// Variant picks the surface, as Input's.
Variant InputVariant
// Size sets the height (24, 32 or 40), padding and font size, as Input's.
Size theme.Size
}
type InputOTPProps ¶
type InputOTPProps struct {
// Length is how many characters the code has: 6 when zero.
Length int
// Alphanumeric takes letters as well as digits.
Alphanumeric bool
// Variant picks the cells' surface, as Input's.
Variant InputVariant
// Size sets the cells' height (24, 32 or 40) and font size, as Input's.
Size theme.Size
// OnComplete runs with the code once all of its characters are in.
OnComplete func(code string)
}
type InputProps ¶
type InputProps struct {
// Variant picks the surface: Outlined sits on the container with a border, Filled uses a
// neutral fill, Borderless has neither.
Variant InputVariant
// Size sets the height (24, 32 or 40), padding, font size and corner radius.
Size theme.Size
// Placeholder shows while the input is empty.
Placeholder string
// Prefix shows an icon before the text.
Prefix *ui.SVG
// Suffix shows an icon after the text.
Suffix *ui.SVG
// Invalid draws the error border, and the error ring while focused.
Invalid bool
}
type InputVariant ¶
type InputVariant int
const ( InputOutlined InputVariant = iota InputFilled InputBorderless )
type PickOptions ¶
PickOptions are what a Picker is asked to pick.
type RichTextEditorProps ¶
type RichTextEditorProps struct {
// Label is the accessible name of the editor.
Label string
// Placeholder is visible when the document is empty.
Placeholder string
// ReadOnly keeps the document selectable without permitting edits.
ReadOnly bool
// HideToolbar shows just the editable document.
HideToolbar bool
// OnChange is called with the document's text after typing or a toolbar edit.
OnChange func(richtext.Text)
}
type RuleEditorProps ¶
type RuleField ¶
type RuleField struct {
// Key identifies the attribute to test. Label is its visible name.
Key, Label string
// Operators are the comparisons available for this attribute.
Operators []RuleOperator
}
type RuleOperator ¶
type RuleSet ¶
type RuleSet struct {
// Any matches when at least one rule matches. Otherwise all rules must match.
Any bool
Rules []*Rule
}
RuleSet is an editable group of comparisons. Keep each rule's pointer while it is in the set.
type SearchBarProps ¶
type SearchBarProps struct {
// Placeholder shows while the query is empty: "Type keywords..." when empty.
Placeholder string
// ShortKey, written as display.Hotkey takes it ("mod+k"), focuses the search from anywhere in
// the window, and shows as a tag at the end while the search is empty and not focused.
ShortKey string
// Platform names the ShortKey's keys and picks what mod means, as display.HotkeyProps's.
Platform display.HotkeyPlatform
// Loading spins a loader in place of the search icon.
Loading bool
// Variant picks the surface, as Input's.
Variant InputVariant
// Size sets the height (24, 32 or 40), padding and font size, as Input's.
Size theme.Size
// OnSearch runs with the query when Enter is pressed.
OnSearch func(query string)
}
type SelectOption ¶
type SelectOption struct {
// Value is what choosing the option puts in the selection.
Value string
// Label is the option's text, in the popup and in the trigger once chosen.
Label string
// Icon shows before the label.
Icon *ui.SVG
// Disabled dims the option and keeps it from being chosen.
Disabled bool
}
type SelectProps ¶
type SelectProps struct {
// Options are the choices, in order.
Options []SelectOption
// Placeholder shows in the trigger while nothing is chosen.
Placeholder string
// Variant picks the trigger's surface, as Input's.
Variant InputVariant
// Size sets the trigger height (24, 32 or 40), padding and font size.
Size theme.Size
// Disabled keeps the select from opening.
Disabled bool
}
type StepperProps ¶
type TextAreaProps ¶
type TextAreaProps struct {
// Variant picks the surface, as Input's.
Variant InputVariant
// Placeholder shows while the text area is empty.
Placeholder string
// MinRows is the height in lines when empty; 0 is 2.
MinRows int
// MaxRows is how many lines it grows to before it scrolls; 0 is 8.
MaxRows int
// Invalid draws the error border, and the error ring while focused.
Invalid bool
}
type TimeOfDay ¶
type TimeOfDay struct {
Hour, Minute, Second int
}
TimeOfDay is a clock time without a date or time zone.
type TimePickerProps ¶
type TimePickerProps struct {
// Label is the accessible name of the group of fields.
Label string
// TwelveHour displays a 1–12 hour field with an AM or PM control.
TwelveHour bool
// Seconds shows a field for seconds in addition to hours and minutes.
Seconds bool
// Disabled prevents changes to the time.
Disabled bool
}
type TokenFieldProps ¶
type UploadProps ¶
type UploadProps struct {
// Accept limits the files taken, as HTML's accept: a comma-separated list of extensions
// (".pdf"), media types ("application/pdf") and kinds of them ("image/*").
Accept string
// Multiple takes several files at once; without it only the first file of a pick or a drop is
// taken.
Multiple bool
// Directory picks folders instead of files, which give the files in them.
Directory bool
// MaxCount is the most files taken at once, after BeforeUpload; no limit when zero.
MaxCount int
// Disabled neither opens the picker nor takes drops.
Disabled bool
// NoClick keeps a click or Enter from opening the picker, for a dragger that only takes drops.
NoClick bool
// Dragger makes a dashed drop zone that also takes files dropped on it; with no content it
// shows an icon, Title and Description.
Dragger bool
// Title is the default dragger's text: "Click or drag file to this area to upload" when empty.
Title string
// Description is a line under the default dragger's Title.
Description string
// BeforeUpload is asked about each accepted file in turn; returning false drops it.
BeforeUpload func(File) bool
// OnFiles gets the files taken, once for each pick or drop that takes any.
OnFiles func([]File)
// Picker shows the picker the click opens, from a goroutine of its own, and returns the files
// chosen, nil when canceled: PickFiles when nil, mygo's Dialog.Open in a native app and a file
// input in a browser.
Picker func(PickOptions) ([]File, error)
}