Widget catalog

Input handling and accessibility

Widgets that draw nothing and add pointer, keyboard, drag and assistive technology behavior to their child. They have examples but no pictures.

interact.GestureDetector

Reports taps, double taps, secondary taps, long presses, drags (start, update, end) and pinches on its child. A press that moves only a little stays a tap. OnTapDownAt, OnTapAt and OnSecondaryTapAt tell the modifier keys held along with the place, for a click with Shift or Ctrl.

Package github.com/bankai-tensei/gowaku/widgets/interact

It draws nothing of its own, so there is no picture.

interact.GestureDetector{
	OnTap:            func() { /* select */ },
	OnDoubleTap:      func() { /* open */ },
	OnSecondaryTapAt: func(layout.Tap) { /* a menu where the press was */ },
	OnLongPress:      func(_ geom.Offset, _ input.PointerDevice) { /* more choices */ },
	OnDragUpdate:     func(_, _ geom.Offset) { /* move by the delta */ },
	Child:            tile("Tap me", 120, 40),
}

interact.MouseRegion

Reports the pointer entering and leaving, and sets the cursor over its child.

Package github.com/bankai-tensei/gowaku/widgets/interact

It draws nothing of its own, so there is no picture.

interact.MouseRegion{
	Cursor:  input.CursorHand,
	OnEnter: func() { /* show the controls */ },
	OnExit:  func() { /* hide them */ },
	Child:   tile("Hover", 120, 40),
}

interact.Listener

Hands every pointer event over its child to a function, with the pressure of a pen, for drawing.

Package github.com/bankai-tensei/gowaku/widgets/interact

It draws nothing of its own, so there is no picture.

interact.Listener{
	OnPointer: func(e *core.PointerEvent) {
		switch e.Kind {
		case core.PointerDown:
			// start a stroke at e.Pos, as wide as e.Pressure for a pen
		case core.PointerMove:
			// add e.Pos to the stroke while one is going
		}
	},
	Child: basic.SizedBox{Width: 300, Height: 200},
}

interact.Focus

Lets its child take the keyboard. Tab moves in the order of painting.

Package github.com/bankai-tensei/gowaku/widgets/interact

It draws nothing of its own, so there is no picture.

interact.Focus{
	Enabled: true,
	OnKey: func(e *core.KeyEvent) bool {
		return e.Key == input.KeySpace // handled; false passes it on
	},
	OnShowFocus: func(_ bool) { /* show a FocusRing while true */ },
	Child:       tile("Focusable", 120, 40),
}

basic.IgnorePointer

Lets the pointer pass through its child to what is below.

Package github.com/bankai-tensei/gowaku/widgets/basic

It draws nothing of its own, so there is no picture.

basic.Stack{Children: []core.Widget{
	control.Button{Label: "Still clickable", OnPress: func() {}},
	basic.IgnorePointer{Child: basic.Container{Width: 160, Height: 30, Color: geom.RGBA(1, 1, 1, 0.2)}},
}}

interact.Draggable

Drags data out of its child: to a DragTarget, another window or another program.

Package github.com/bankai-tensei/gowaku/widgets/interact

It draws nothing of its own, so there is no picture.

interact.Draggable{
	Data:      input.DragData{Text: "notes.txt"},
	Allowed:   input.DropCopy | input.DropMove,
	OnDragEnd: func(_ input.DropEffect) { /* remove the row on DropMove */ },
	Child:     tile("notes.txt", 120, 32),
}

interact.DragTarget

Takes text or files dropped on its child, from this window or from programs such as Explorer or a browser.

Package github.com/bankai-tensei/gowaku/widgets/interact

It draws nothing of its own, so there is no picture.

interact.DragTarget{
	Kinds:   input.DataFiles,
	OnHover: func(_ bool) { /* light up while true */ },
	OnDrop:  func(_ input.DragData, _ geom.Offset) { /* open the files */ },
	Child:   tile("Drop files here", 240, 120),
}

interact.Semantics

Describes its child to assistive technology and does what a screen reader asks. The standard controls have their own.

Package github.com/bankai-tensei/gowaku/widgets/interact

It draws nothing of its own, so there is no picture.

interact.Semantics{
	Role: semantics.RoleButton, Label: "Play", Hint: "Plays the album from the start",
	OnTap: func() { /* play */ },
	Child: basic.Icon{Path: triangleIcon()},
}

interact.ExcludeSemantics

Hides its child from assistive technology, as aria-hidden does, for text that only decorates, such as the initial in an avatar. It is still drawn and still takes the pointer.

Package github.com/bankai-tensei/gowaku/widgets/interact

It draws nothing of its own, so there is no picture.

basic.Row{Size: layout.MainMin, Spacing: theme.Space8, Children: []core.Widget{
	// The initial only decorates; the name beside it is read.
	interact.ExcludeSemantics{Child: basic.Text{Content: "S"}},
	basic.Text{Content: "Sato Hana"},
}}

interact.FocusTraversalOrder

Sets where the controls below it come in the order of Tab, as tabindex does in HTML.

Package github.com/bankai-tensei/gowaku/widgets/interact

It draws nothing of its own, so there is no picture.

basic.Column{Children: []core.Widget{
	field.Input{Label: "Details", OnChange: func(string) {}},
	// Tab reaches the search field first, wherever it is painted.
	interact.FocusTraversalOrder{Order: 1, Child: field.Search{OnChange: func(string) {}}},
}}