Index | Files | Directories

package widget

import ""

Package widget implements state tracking and event handling of common user interface controls. To draw widgets, use a theme packages such as package


Package Files

buffer.go button.go checkbox.go doc.go editor.go enum.go label.go

type Button Uses

type Button struct {
    // contains filtered or unexported fields

func (*Button) Clicked Uses

func (b *Button) Clicked(gtx *layout.Context) bool

func (*Button) History Uses

func (b *Button) History() []Click

func (*Button) Layout Uses

func (b *Button) Layout(gtx *layout.Context)

type ChangeEvent Uses

type ChangeEvent struct{}

A ChangeEvent is generated for every user change to the text.

type CheckBox Uses

type CheckBox struct {
    // contains filtered or unexported fields

func (*CheckBox) Checked Uses

func (c *CheckBox) Checked(gtx *layout.Context) bool

func (*CheckBox) Layout Uses

func (c *CheckBox) Layout(gtx *layout.Context)

func (*CheckBox) SetChecked Uses

func (c *CheckBox) SetChecked(value bool)

type Click Uses

type Click struct {
    Position f32.Point
    Time     time.Time

Click represents a historic click.

type Editor Uses

type Editor struct {
    Alignment text.Alignment
    // SingleLine force the text to stay on a single line.
    // SingleLine also sets the scrolling direction to
    // horizontal.
    SingleLine bool
    // Submit enabled translation of carriage return keys to SubmitEvents.
    // If not enabled, carriage returns are inserted as newlines in the text.
    Submit bool
    // contains filtered or unexported fields

Editor implements an editable and scrollable text area.

func (*Editor) CaretCoords Uses

func (e *Editor) CaretCoords() (x fixed.Int26_6, y int)

CaretCoords returns the x & y coordinates of the caret, relative to the editor itself.

func (*Editor) CaretPos Uses

func (e *Editor) CaretPos() (line, col int)

CaretPos returns the line & column numbers of the caret.

func (*Editor) Delete Uses

func (e *Editor) Delete(runes int)

Delete runes from the caret position. The sign of runes specifies the direction to delete: positive is forward, negative is backward.

func (*Editor) Events Uses

func (e *Editor) Events(gtx *layout.Context) []EditorEvent

Events returns available editor events.

func (*Editor) Focus Uses

func (e *Editor) Focus()

Focus requests the input focus for the Editor.

func (*Editor) Focused Uses

func (e *Editor) Focused() bool

Focused returns whether the editor is focused or not.

func (*Editor) Insert Uses

func (e *Editor) Insert(s string)

Insert inserts text at the caret, moving the caret forward.

func (*Editor) Layout Uses

func (e *Editor) Layout(gtx *layout.Context, sh text.Shaper, font text.Font, size unit.Value)

Layout lays out the editor.

func (*Editor) Len Uses

func (e *Editor) Len() int

Len is the length of the editor contents.

func (*Editor) Move Uses

func (e *Editor) Move(distance int)

Move the caret: positive distance moves forward, negative distance moves backward.

func (*Editor) NumLines Uses

func (e *Editor) NumLines() int

NumLines returns the number of lines in the editor.

func (*Editor) PaintCaret Uses

func (e *Editor) PaintCaret(gtx *layout.Context)

func (*Editor) PaintText Uses

func (e *Editor) PaintText(gtx *layout.Context)

func (*Editor) SetText Uses

func (e *Editor) SetText(s string)

SetText replaces the contents of the editor.

func (*Editor) Text Uses

func (e *Editor) Text() string

Text returns the contents of the editor.

type EditorEvent Uses

type EditorEvent interface {
    // contains filtered or unexported methods

type Enum Uses

type Enum struct {
    // contains filtered or unexported fields

func (*Enum) Layout Uses

func (rg *Enum) Layout(gtx *layout.Context, key string)

Layout adds the event handler for key.

func (*Enum) SetValue Uses

func (rg *Enum) SetValue(value string)

func (*Enum) Value Uses

func (e *Enum) Value(gtx *layout.Context) string

Value processes events and returns the last selected value, or the empty string.

type Label Uses

type Label struct {
    // Alignment specify the text alignment.
    Alignment text.Alignment
    // MaxLines limits the number of lines. Zero means no limit.
    MaxLines int

Label is a widget for laying out and drawing text.

func (Label) Layout Uses

func (l Label) Layout(gtx *layout.Context, s text.Shaper, font text.Font, size unit.Value, txt string)

type SubmitEvent Uses

type SubmitEvent struct {
    Text string

A SubmitEvent is generated when Submit is set and a carriage return key is pressed.


materialPackage material implements the Material design.

Package widget imports 17 packages (graph) and is imported by 9 packages. Updated 2020-03-28. Refresh now. Tools for package owners.