Documentation ¶
Index ¶
- Constants
- type Button
- func (b *Button) Draw(con *console.Console, timeElapsed float64)
- func (b *Button) FocusOnClick() bool
- func (b *Button) SetBackground(bg, bgHover, bgClicked *consolecolor.Color)
- func (b *Button) SetForeground(f, fHover, fClicked *consolecolor.Color)
- func (b *Button) Update(con *console.Console, timeElapsed float64) bool
- type ClickedCallback
- type ComponentState
- type EnterCallback
- type TextBox
- func (tb *TextBox) Draw(con *console.Console, timeElapsed float64)
- func (tb *TextBox) FocusOnClick() bool
- func (tb *TextBox) GetText() string
- func (tb *TextBox) SetBackground(bg, bgHover, bgClicked *consolecolor.Color)
- func (tb *TextBox) SetEnterCallback(callback EnterCallback)
- func (tb *TextBox) SetForeground(f, fInactive *consolecolor.Color)
- func (tb *TextBox) SetText(newText string)
- func (tb *TextBox) SetTextChanged(callback TextChangeCallback)
- func (tb *TextBox) Update(con *console.Console, timeElapsed float64) bool
- type TextChangeCallback
Constants ¶
const ( // ComponentIdle means the component is neither clicked not hovered over. ComponentIdle = ComponentState(0) // ComponentHovered means the component is hovered over ComponentHovered = ComponentState(1) // ComponentClicked means the component is hovered over and the left mouse button is currently pressed. ComponentClicked = ComponentState(2) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Button ¶
type Button struct { *console.ComponentBase // contains filtered or unexported fields }
Button represents a button that you can click.
func NewButton ¶
func NewButton(x, y, width, height int, text string, callback ClickedCallback) *Button
NewButton creates a new button at the given position, size and text.
func (*Button) FocusOnClick ¶
FocusOnClick returns true if a click should focus the button
func (*Button) SetBackground ¶
func (b *Button) SetBackground(bg, bgHover, bgClicked *consolecolor.Color)
SetBackground sets the background colors for the button states. Parameters that are nil will be ignored and not set.
func (*Button) SetForeground ¶
func (b *Button) SetForeground(f, fHover, fClicked *consolecolor.Color)
SetForeground sets the foreground colors for the button states. Parameters that are nil will be ignored and not set.
type ClickedCallback ¶
type ClickedCallback func()
ClickedCallback will be called if a click on the component happened.
type ComponentState ¶
type ComponentState int
ComponentState represents generic states that components can use to define logic.
func CalculateComponentState ¶
func CalculateComponentState(con *console.Console, x, y, w, h int) ComponentState
CalculateComponentState is generic helper function to calculate the state of a given area in the console.
type EnterCallback ¶
type EnterCallback func()
EnterCallback will be called if the enter key has been pressed.
type TextBox ¶
type TextBox struct { *console.ComponentBase // contains filtered or unexported fields }
TextBox represents a box that you can type in.
func NewTextbox ¶
NewTextbox creates a new textbox at the given position and size.
func (*TextBox) FocusOnClick ¶
FocusOnClick returns true if a click should focus the textbox
func (*TextBox) SetBackground ¶
func (tb *TextBox) SetBackground(bg, bgHover, bgClicked *consolecolor.Color)
SetBackground sets the background colors for textbox. Parameters that are nil will be ignored and not set.
func (*TextBox) SetEnterCallback ¶
func (tb *TextBox) SetEnterCallback(callback EnterCallback)
SetEnterCallback sets the enter callback.
func (*TextBox) SetForeground ¶
func (tb *TextBox) SetForeground(f, fInactive *consolecolor.Color)
SetForeground sets the foreground colors for the textbox states. Parameters that are nil will be ignored and not set.
func (*TextBox) SetTextChanged ¶
func (tb *TextBox) SetTextChanged(callback TextChangeCallback)
SetTextChanged sets the text change callback.
type TextChangeCallback ¶
type TextChangeCallback func(text string)
TextChangeCallback will be called if a text of the component has been changed.