The EditView element is a test editor and extends the View interface.

To create an EditView, the function is used:

func NewEditView(session Session, params Params) EditView

Several options for editable text are possible. The type of the edited text is set usingthe int property "edit-view-type" (EditViewType constant).This property can take the following values:

Value Constant Name Editor type
0 SingleLineText "text" One-line text editor. Default value
1 PasswordText "password" Password editor. The text is hidden by asterisks
2 EmailText "email" Single e-mail editor
3 EmailsText "emails" Multiple e-mail editor
4 URLText "url" Internet address input editor
5 PhoneText "phone" Phone number editor
6 MultiLineText "multiline" Multi-Line Text Editor

To simplify the text of the program, you can use the "type" properties (Type constant) instead of the "edit-view-type".These property names are synonymous. But when describing the style, "type" cannot be used.

To set/get edited text, use the string property "text" (Text constant)

The maximum length of editable text is set using the "max-length" int property (MaxLength constant).

You can limit the input text using a regular expression. To do this, use the string property"edit-view-pattern" (EditViewPattern constant). Instead of "edit-view-pattern", you can use the synonym "pattern"(Pattern constant), except for the style description.

To prohibit text editing, use the bool property "readonly" (ReadOnly constant).

To enable / disable the built-in spell checker, use the bool "spellcheck" property (Spellcheck constant).Spell checking can only be enabled if the editor type is set to SingleLineText or MultiLineText.

For the editor, you can set a hint that will be shown while the editor is empty.To do this, use the string property "hint" (Hint constant).

For a multi-line editor, auto-wrap mode can be enabled. The bool property "edit-wrap" (EditWrap constant) is used for this.If "edit-wrap" is false (default), then horizontal scrolling is used.If enabled, the text wraps to a new line when the EditView border is reached.

To change the color of the text input caret, use the Color property "caret-color" (CaretColor constant).The "caret-color" property can be set not only for EditView, but for any container.In this case, the color of the caret changes for all child EditViews placed in this container.

The following functions can be used to get the values of the properties of an EditView:

func GetText(view View, subviewID ...string) string
func GetHint(view View, subviewID ...string) string
func GetMaxLength(view View, subviewID ...string) int
func GetEditViewType(view View, subviewID ...string) int
func GetEditViewPattern(view View, subviewID ...string) string
func IsReadOnly(view View, subviewID ...string) bool
func IsEditViewWrap(view View, subviewID ...string) bool
func IsSpellcheck(view View, subviewID ...string) bool
func GetCaretColor(view View, subviewID ...string) Color

The "edit-text-changed" event (EditTextChangedEvent constant) is used to track changes to the text.The main event listener has the following format:

func(EditView, string, string)

where the second argument is the new text value, the third argument is the previous text value.

Additional event listeners can have the following format

func(EditView, newText string)
func(newText, oldText string)
func(newText string)

You can get the current list of text change listeners using the function

func GetTextChangedListeners(view View, subviewID ...string) []func(EditView, string, string)