Documentation
¶
Overview ¶
Package textinput provides a text-inputting controller. This package is experimental and the API might be changed in the future.
This package is supported on Windows, macOS, and Web browsers so far.
Index ¶
- type Field
- func (f *Field) Blur()
- func (f *Field) CompositionSelection() (startInBytes, endInBytes int, ok bool)
- func (f *Field) Focus()
- func (f *Field) HandleInput(x, y int) (handled bool, err error)deprecated
- func (f *Field) HandleInputWithBounds(bounds image.Rectangle) (handled bool, err error)
- func (f *Field) IsFocused() bool
- func (f *Field) Selection() (startInBytes, endInBytes int)
- func (f *Field) SetSelection(startInBytes, endInBytes int)
- func (f *Field) SetTextAndSelection(text string, selectionStartInBytes, selectionEndInBytes int)
- func (f *Field) Text() string
- func (f *Field) TextForRendering() string
- func (f *Field) UncommittedTextLengthInBytes() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶ added in v2.7.0
type Field struct {
// contains filtered or unexported fields
}
Field is a region accepting text inputting with IME.
Field is not focused by default. You have to call Focus when you start text inputting.
Field is a wrapper of the low-level API like Start.
For an actual usage, see the examples "textinput".
func (*Field) CompositionSelection ¶ added in v2.7.0
CompositionSelection returns the current composition selection in bytes if a text is composited. If a text is not composited, this returns 0s and false. The returned values indicate relative positions in bytes where the current composition text's start is 0.
func (*Field) Focus ¶ added in v2.7.0
func (f *Field) Focus()
Focus focuses the field. A Field has to be focused to start text inputting.
There can be only one Field that is focused at the same time. When Focus is called and there is already a focused field, Focus removes the focus of that.
func (*Field) HandleInput
deprecated
added in
v2.7.0
HandleInput updates the field state. HandleInput must be called every tick, i.e., every Update, when Field is focused. HandleInput takes a position where an IME window is shown if needed.
HandleInput returns whether the text inputting is handled or not. If HandleInput returns true, a Field user should not handle further input events.
HandleInput returns an error when handling input causes an error.
Deprecated: use HandleInputWithBounds instead.
func (*Field) HandleInputWithBounds ¶ added in v2.9.0
HandleInputWithBounds updates the field state. HandleInputWithBounds must be called every tick, i.e., every Update, when Field is focused. HandleInputWithBounds takes a character bounds, which decides the position where an IME window is shown if needed. The bounds width doesn't matter very much as long as it is greater than 0. The bounds height should be the text height like a cursor height.
HandleInputWithBounds returns whether the text inputting is handled or not. If HandleInputWithBounds returns true, a Field user should not handle further input events.
HandleInputWithBounds returns an error when handling input causes an error.
func (*Field) SetSelection ¶ added in v2.7.0
SetSelection sets the selection range.
func (*Field) SetTextAndSelection ¶ added in v2.7.0
SetTextAndSelection sets the text and the selection range.
func (*Field) Text ¶ added in v2.7.0
Text returns the current text. The returned value doesn't include compositing texts.
func (*Field) TextForRendering ¶ added in v2.7.0
TextForRendering returns the text for rendering. The returned value includes compositing texts.
func (*Field) UncommittedTextLengthInBytes ¶ added in v2.9.0
UncommittedTextLengthInBytes returns the compositing text length in bytes when the field is focused and the text is editing. The uncommitted text range is from the selection start to the selection start + the uncommitted text length. UncommittedTextLengthInBytes returns 0 otherwise.