messeji

package
v0.0.0-...-500cae8 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 14 Imported by: 0

README

messeji

GoDoc Donate via LiberaPay Donate via Patreon

Text widgets for Ebitengine

Note: IME is not yet supported.

Demo

Try messeji

The code for this demo is located in examples/messeji.

Documentation

Documentation is available via godoc.

Support

Please share issues and suggestions here.

Screenshot

Screenshot

Documentation

Overview

Package messeji provides text widgets for Ebitengine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alignment

type Alignment int

Alignment specifies how text is aligned within the field.

const (
	// AlignStart aligns text at the start of the field.
	AlignStart Alignment = 0

	// AlignCenter aligns text at the center of the field.
	AlignCenter Alignment = 1

	// AlignEnd aligns text at the end of the field.
	AlignEnd Alignment = 2
)

type InputField

type InputField struct {
	*TextField

	sync.Mutex
	// contains filtered or unexported fields
}

InputField is a text input field. Call Update and Draw when your Game's Update and Draw methods are called.

Note: A position and size must be set via SetRect before the field will appear. Keyboard events are not handled by default, and may be enabled via SetHandleKeyboard.

func NewInputField

func NewInputField(face font.Face, faceMutex *sync.Mutex) *InputField

NewInputField returns a new InputField. See type documentation for more info.

func (*InputField) HandleKeyboardEvent

func (f *InputField) HandleKeyboardEvent(key ebiten.Key, r rune) (handled bool, err error)

HandleKeyboardEvent passes the provided key or rune to the Inputfield.

func (*InputField) SetChangedFunc

func (f *InputField) SetChangedFunc(changedFunc func(r rune) (accept bool))

SetChangedFunc sets a handler which is called when the text buffer is changed. The handler may return true to add the rune to the text buffer.

func (*InputField) SetHandleKeyboard

func (f *InputField) SetHandleKeyboard(handle bool)

SetHandleKeyboard sets a flag controlling whether keyboard input should be handled by the field. This can be used to facilitate focus changes between multiple inputs.

func (*InputField) SetSelectedFunc

func (f *InputField) SetSelectedFunc(selectedFunc func() (accept bool))

SetSelectedFunc sets a handler which is called when the enter key is pressed. Providing a nil function value will remove the existing handler (if set). The handler may return true to clear the text buffer.

func (*InputField) Update

func (f *InputField) Update() error

Update updates the input field. This function should be called when Game.Update is called.

type TextField

type TextField struct {
	sync.Mutex
	// contains filtered or unexported fields
}

TextField is a text display field. Call Update and Draw when your Game's Update and Draw methods are called.

Note: A position and size must be set via SetRect before the field will appear. Keyboard events are not handled by default, and may be enabled via SetHandleKeyboard.

func NewTextField

func NewTextField(face font.Face, faceMutex *sync.Mutex) *TextField

NewTextField returns a new TextField. See type documentation for more info.

func (*TextField) Draw

func (f *TextField) Draw(screen *ebiten.Image)

Draw draws the field on the screen. This function should be called when Game.Draw is called.

func (*TextField) ForegroundColor

func (f *TextField) ForegroundColor() color.RGBA

ForegroundColor returns the color of the text within the field.

func (*TextField) HandleKeyboardEvent

func (f *TextField) HandleKeyboardEvent(key ebiten.Key, r rune) (handled bool, err error)

HandleKeyboardEvent passes the provided key or rune to the TextField.

func (*TextField) HandleMouseEvent

func (f *TextField) HandleMouseEvent(cursor image.Point, pressed bool, clicked bool) (handled bool, err error)

func (*TextField) LineHeight

func (f *TextField) LineHeight() int

LineHeight returns the line height for the field.

func (*TextField) Padding

func (f *TextField) Padding() int

Padding returns the amount of padding around the text within the field.

func (*TextField) Rect

func (f *TextField) Rect() image.Rectangle

Rect returns the position and size of the field.

func (*TextField) SetAutoHideScrollBar

func (f *TextField) SetAutoHideScrollBar(autoHide bool)

SetAutoHideScrollBar sets whether the scroll bar is automatically hidden when the entire text buffer is visible.

func (*TextField) SetBackgroundColor

func (f *TextField) SetBackgroundColor(c color.RGBA)

SetBackgroundColor sets the color of the background of the field.

func (*TextField) SetFollow

func (f *TextField) SetFollow(follow bool)

SetFollow sets whether the field should automatically scroll to the end when content is added to the buffer.

func (*TextField) SetFont

func (f *TextField) SetFont(face font.Face, mutex *sync.Mutex)

SetFont sets the font face of the text within the field.

func (*TextField) SetForegroundColor

func (f *TextField) SetForegroundColor(c color.RGBA)

SetForegroundColor sets the color of the text within the field.

func (*TextField) SetHandleKeyboard

func (f *TextField) SetHandleKeyboard(handle bool)

SetHandleKeyboard sets a flag controlling whether keyboard input should be handled by the field. This can be used to facilitate focus changes between multiple inputs.

func (*TextField) SetHorizontal

func (f *TextField) SetHorizontal(h Alignment)

SetHorizontal sets the horizontal alignment of the text within the field.

func (*TextField) SetLineHeight

func (f *TextField) SetLineHeight(height int)

SetLineHeight sets a custom line height for the field. Setting a line height of 0 restores the automatic line height detection based on the font.

func (*TextField) SetMask

func (f *TextField) SetMask(r rune)

SetMask sets the rune used to mask the text buffer contents. Set to 0 to disable.

func (*TextField) SetPadding

func (f *TextField) SetPadding(padding int)

SetPadding sets the amount of padding around the text within the field.

func (*TextField) SetPrefix

func (f *TextField) SetPrefix(text string)

SetPrefix sets the text shown before the content of the field.

func (*TextField) SetRect

func (f *TextField) SetRect(r image.Rectangle)

SetRect sets the position and size of the field.

func (*TextField) SetScrollBarColors

func (f *TextField) SetScrollBarColors(area color.RGBA, handle color.RGBA)

SetScrollBarColors sets the color of the scroll bar area and handle.

func (*TextField) SetScrollBarVisible

func (f *TextField) SetScrollBarVisible(scrollVisible bool)

SetScrollBarVisible sets whether the scroll bar is visible on the screen.

func (*TextField) SetScrollBarWidth

func (f *TextField) SetScrollBarWidth(width int)

SetScrollBarWidth sets the width of the scroll bar.

func (*TextField) SetScrollBorderColors

func (f *TextField) SetScrollBorderColors(top color.RGBA, right color.RGBA, bottom color.RGBA, left color.RGBA)

SetScrollBorderColor sets the color of the top, right, bottom and left border of the scroll bar handle.

func (*TextField) SetScrollBorderSize

func (f *TextField) SetScrollBorderSize(size int)

SetScrollBorderSize sets the size of the border around the scroll bar handle.

func (*TextField) SetSingleLine

func (f *TextField) SetSingleLine(single bool)

SetSingleLine sets whether the field displays all text on a single line. When enabled, the field scrolls horizontally. Otherwise, it scrolls vertically.

func (*TextField) SetSuffix

func (f *TextField) SetSuffix(text string)

SetSuffix sets the text shown after the content of the field.

func (*TextField) SetText

func (f *TextField) SetText(text string)

SetText sets the text in the field.

func (*TextField) SetVertical

func (f *TextField) SetVertical(v Alignment)

SetVertical sets the veritcal alignment of the text within the field.

func (*TextField) SetVisible

func (f *TextField) SetVisible(visible bool)

SetVisible sets whether the field is visible on the screen.

func (*TextField) SetWordWrap

func (f *TextField) SetWordWrap(wrap bool)

SetWordWrap sets a flag which, when enabled, causes text to wrap without breaking words.

func (*TextField) Text

func (f *TextField) Text() string

Text returns the text in the field.

func (*TextField) Update

func (f *TextField) Update() error

Update updates the field. This function should be called when Game.Update is called.

func (*TextField) Visible

func (f *TextField) Visible() bool

Visible returns whether the field is currently visible on the screen.

func (*TextField) WordWrap

func (f *TextField) WordWrap() bool

WordWrap returns the current text wrap mode.

func (*TextField) Write

func (f *TextField) Write(p []byte) (n int, err error)

Write writes to the field's buffer.

Jump to

Keyboard shortcuts

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