Documentation ¶
Overview ¶
Package magicform helps create simple form layouts with go/ui.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
type Field struct { // Type may be inferred by presence of other params. Type Type // Set a text string and font for simple labels or paragraphs. Label string Font render.Text // Easy button row: make Buttons an array of Button fields Buttons []Field ButtonStyle *style.Button // Easy Paginator. DO NOT SUPERVISE, let the Create do so! Pager *ui.Pager // If you send a *ui.Frame to insert, the Type is inferred // to be Frame. Frame *ui.Frame // Variable bindings, the type may infer to be: BoolVariable *bool // Checkbox TextVariable *string // Textbox IntVariable *int // Textbox Options []Option // Selectbox SelectValue interface{} // Selectbox default choice Color *render.Color // Color Readonly bool // draw the value as a flat label // For text-type fields, opt-in to let magicform prompt the // user using the game's developer shell. PromptUser func(answer string) // Tooltip to add to a form control. // Checkbox only for now. Tooltip ui.Tooltip // config for the tooltip only // Handlers you can configure OnSelect func(value interface{}) // Selectbox OnClick func() // Button }
Field for your form (or form-aligned label sections, etc.)
The type of Form control to render is inferred based on bound variables and other configuration.
func (Field) Infer ¶
Infer the type if the field was of type Auto.
Returns the first Type inferred from the field by checking in this order:
- Frame if the field has a *Frame - Checkbox if there is a *BoolVariable - Selectbox if there are Options - Textbox if there is a *TextVariable - Text if there is a Label
May return Auto if none of the above and be ignored.
type Form ¶
type Form struct { Supervisor *ui.Supervisor // Required for most useful forms Engine render.Engine // For vertical forms. Vertical bool LabelWidth int // size of left frame for labels. PadY int // spacer between (vertical) forms PadX int }
Form configuration.
Click to show internal directories.
Click to hide internal directories.