textfield

package
v0.0.0-...-af996ba Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2019 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// StdTheme is the theme all new TextFields get by default.
	StdTheme = NewTheme()
)

Functions

This section is empty.

Types

type TextField

type TextField struct {
	widget.Block

	Theme *Theme // The theme the text field will use to draw itself.
	// contains filtered or unexported fields
}

TextField provides a single-line text input control.

func New

func New() *TextField

New creates a new, empty, text field.

func (*TextField) CanCopy

func (field *TextField) CanCopy() bool

CanCopy returns true if the field has a selection that can be copied.

func (*TextField) CanCut

func (field *TextField) CanCut() bool

CanCut returns true if the field has a selection that can be cut.

func (*TextField) CanDelete

func (field *TextField) CanDelete() bool

CanDelete returns true if the field has a selection that can be deleted.

func (*TextField) CanPaste

func (field *TextField) CanPaste() bool

CanPaste returns true if the clipboard has content that can be pasted into the field.

func (*TextField) CanSelectAll

func (field *TextField) CanSelectAll() bool

CanSelectAll returns true if the field's selection can be expanded.

func (*TextField) Copy

func (field *TextField) Copy()

Copy the selected text to the clipboard.

func (*TextField) Cut

func (field *TextField) Cut()

Cut the selected text to the clipboard.

func (*TextField) Delete

func (field *TextField) Delete()

Delete removes the currently selected text, if any.

func (*TextField) FromSelectionIndex

func (field *TextField) FromSelectionIndex(index int) geom.Point

FromSelectionIndex returns a location in local coordinates for the specified rune index.

func (*TextField) HasSelectionRange

func (field *TextField) HasSelectionRange() bool

HasSelectionRange returns true is a selection range is currently present.

func (*TextField) Paste

func (field *TextField) Paste()

Paste any text on the clipboard into the field.

func (*TextField) SelectAll

func (field *TextField) SelectAll()

SelectAll selects all of the text in the field.

func (*TextField) SelectedText

func (field *TextField) SelectedText() string

SelectedText returns the currently selected text.

func (*TextField) Selection

func (field *TextField) Selection() (start, end int)

Selection returns the current start and end selection indexes.

func (*TextField) SelectionCount

func (field *TextField) SelectionCount() int

SelectionCount returns the number of characters currently selected.

func (*TextField) SetSelection

func (field *TextField) SetSelection(start, end int)

SetSelection sets the start and end range of the selection. Values beyond either end will be constrained to the appropriate end. Likewise, an end value less than the start value will be treated as if the start and end values were the same.

func (*TextField) SetSelectionTo

func (field *TextField) SetSelectionTo(pos int)

SetSelectionTo moves the cursor to the specified index and removes any range that may have been present.

func (*TextField) SetSelectionToEnd

func (field *TextField) SetSelectionToEnd()

SetSelectionToEnd moves the cursor to the end of the text and removes any range that may have been present.

func (*TextField) SetSelectionToStart

func (field *TextField) SetSelectionToStart()

SetSelectionToStart moves the cursor to the beginning of the text and removes any range that may have been present.

func (*TextField) SetText

func (field *TextField) SetText(text string) bool

SetText sets the content of the field. Returns true if a modification was made.

func (*TextField) SetWatermark

func (field *TextField) SetWatermark(text string)

SetWatermark sets the watermark. The watermark is used to give the user a hint about what the field is for when it is empty.

func (*TextField) Sizes

func (field *TextField) Sizes(hint geom.Size) (min, pref, max geom.Size)

Sizes implements Sizer

func (*TextField) Text

func (field *TextField) Text() string

Text returns the content of the field.

func (*TextField) ToSelectionIndex

func (field *TextField) ToSelectionIndex(x float64) int

ToSelectionIndex returns the rune index for the specified x-coordinate.

func (*TextField) Watermark

func (field *TextField) Watermark() string

Watermark returns the current watermark, if any.

type Theme

type Theme struct {
	Font                    *font.Font    // The font to use.
	Border                  border.Border // The border to use when not focused.
	FocusBorder             border.Border // The border to use when focused.
	BlinkRate               time.Duration // The rate at which the cursor blinks.
	MinimumTextWidth        float64       // The minimum space to permit for text.
	DisabledBackgroundColor color.Color   // The color to use for the background when disabled.
	InvalidBackgroundColor  color.Color   // The color to use for the background when marked invalid.
}

Theme contains the theme elements for TextFields.

func NewTheme

func NewTheme() *Theme

NewTheme creates a new TextField theme.

func (*Theme) Init

func (theme *Theme) Init()

Init initializes the theme with its default values.

Jump to

Keyboard shortcuts

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