button

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2022 License: MIT Imports: 4 Imported by: 15

Documentation

Overview

Package button provides a clickable widget which can be decorated.

Index

Constants

This section is empty.

Variables

View Source
var (
	BareDecoration   = Decoration{Left: "", Right: ""}
	NormalDecoration = Decoration{Left: "<", Right: ">"}
	AltDecoration    = Decoration{Left: "[", Right: "]"}
)

Functions

func Render

func Render(w IWidget, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.ICanvas

func RenderSize

func RenderSize(w IWidget, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.IRenderBox

func SubWidgetSize

func SubWidgetSize(w IWidget, size interface{}, focus gowid.Selector, app gowid.IApp) gowid.IRenderSize

func UserInput

func UserInput(w IClickableIdentityWidget, ev interface{}, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) bool

Types

type Decoration

type Decoration struct {
	Left  string
	Right string
}

Decoration is a simple struct that implements IDecoratedAround.

func (*Decoration) LeftDec

func (b *Decoration) LeftDec() string

func (*Decoration) RightDec

func (b *Decoration) RightDec() string

func (*Decoration) SetLeftDec

func (w *Decoration) SetLeftDec(dec string, app gowid.IApp)

func (*Decoration) SetRightDec

func (w *Decoration) SetRightDec(dec string, app gowid.IApp)

type IClickableIdentityWidget

type IClickableIdentityWidget interface {
	gowid.IClickableWidget
	gowid.IIdentity
}

type ICustomKeys

type ICustomKeys interface {
	CustomSelectKeys() bool
	SelectKeys() []gowid.IKey // can't be nil
}

type IDecoratedAround

type IDecoratedAround interface {
	LeftDec() string
	RightDec() string
}

IDecoratedAround is the interface for any type that provides "decoration" on its left and right side e.g. for buttons, something like "<" and ">".

type IDecoratedMiddle

type IDecoratedMiddle interface {
	MiddleDec() string
}

IDecoratedMiddle is implemented by any type that provides "decoration" in the middle of its render, such as a 'x' or a '-' symbol on a checked button.

type IWidget

type IWidget interface {
	gowid.ICompositeWidget
	IDecoratedAround
}

IWidget is implemented by any widget that contains exactly one exposed subwidget (ICompositeWidget) and that is decorated on its left and right (IDecoratedAround).

type Options

type Options struct {
	Decoration
	SelectKeysProvided bool
	SelectKeys         []gowid.IKey
}

type Widget

type Widget struct {
	*gowid.Callbacks
	gowid.SubWidgetCallbacks
	gowid.ClickCallbacks
	*Decoration
	gowid.AddressProvidesID
	gowid.IsSelectable
	// contains filtered or unexported fields
}

func New

func New(inner gowid.IWidget, opts ...Options) *Widget

func NewAlt

func NewAlt(inner gowid.IWidget) *Widget

func NewBare

func NewBare(inner gowid.IWidget) *Widget

func NewDecorated

func NewDecorated(inner gowid.IWidget, decoration Decoration) *Widget

func (*Widget) Click

func (w *Widget) Click(app gowid.IApp)

func (*Widget) CustomSelectKeys

func (w *Widget) CustomSelectKeys() bool

func (*Widget) Render

func (w *Widget) Render(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.ICanvas

func (*Widget) RenderSize

func (w *Widget) RenderSize(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.IRenderBox

func (*Widget) SelectKeys

func (w *Widget) SelectKeys() []gowid.IKey

func (*Widget) SetLeftDec

func (w *Widget) SetLeftDec(dec string, app gowid.IApp)

func (*Widget) SetRightDec

func (w *Widget) SetRightDec(dec string, app gowid.IApp)

func (*Widget) SetSubWidget

func (w *Widget) SetSubWidget(wi gowid.IWidget, app gowid.IApp)

func (*Widget) String

func (w *Widget) String() string

func (*Widget) SubWidget

func (w *Widget) SubWidget() gowid.IWidget

func (*Widget) SubWidgetSize

func (w *Widget) SubWidgetSize(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.IRenderSize

func (*Widget) UserInput

func (w *Widget) UserInput(ev interface{}, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL