EditView
One line
Multiline
An element that allows to input and edit text
Create from source
func NewEditView(session Session, params Params) EditView
Create new edit view object and returns its interface
Create from resource
EditView {
id = editView,
hint = "hint text",
}
Interface description
Inherit methods, properties and events from View
AppendText(text string)
Append text to the current text of EditView
Properties
"caret-color"
Sets the color of the insertion caret, the visible marker where the next character typed will be inserted. This is sometimes referred to as the text input cursor
Constant: CaretColor
Types: Color
, string
Internal type is Color
, other types converted to it during assignment
See Color
description for more details
Examples
EditView {
caret-color = blue,
}
editor := rui.NewEditView(session, rui.Params{
rui.CaretColor: rui.Blue,
})
"data-list"
Array of recommended values
Constant: DataList
Types: []string
, string
, []fmt.Stringer
, []Color
, []SizeUnit
, []AngleUnit
, []any
containing elements of string
, fmt.Stringer
, bool
, rune
, float32
, float64
, int
, int8
… int64
, uint
, uint8
… uint64
Internal type is []string
, other types converted to it during assignment
Conversion rules
string
- contain single item
[]string
- an array of items
[]fmt.Stringer
- an array of objects convertible to a string
[]Color
- An array of color values which will be converted to a string array
[]SizeUnit
- an array of size unit values which will be converted to a string array
[]any
- this array must contain only types which were listed in Types section
Examples
EditView {
data-list = [
"Value 1",
"Value 2",
],
}
EditView {
data-list = [
1px,
1em,
],
}
EditView {
data-list = [
#FF000000,
#FFFFFFFF,
],
}
editor := rui.NewEditView(session, rui.Params{
rui.DataList: []string{
"Value 1",
"Value 2",
},
})
editor := rui.NewEditView(session, rui.Params{
rui.DataList: []rui.SizeUnit{
rui.Px(1),
rui.Em(1),
},
})
editor := rui.NewEditView(session, rui.Params{
rui.DataList: []rui.Color{
rui.Black,
rui.White,
},
})
"edit-view-pattern"
Regular expression to limit editing of a text
Constant: EditViewPattern
Types: string
Examples
EditView {
edit-view-pattern = "[0-9]{5}",
}
editor := rui.NewEditView(session, rui.Params{
rui.EditViewPattern: "[0-9]{5}",
})
"edit-view-type"
Type of the text input. Default value is "text"
Constant: EditViewType
Types: int
, string
Values
int | string | Description |
---|---|---|
0 (SingleLineText ) |
"text" | One-line text editor |
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 |
"edit-wrap"
Controls whether the text will wrap around when edit view border has been reached. Default value is false
Constant: EditWrap
Types: bool
, int
, string
Values
bool | int | string | Description |
---|---|---|---|
true |
1 |
"true", "yes", "on", "1" | Text wrapped to the next line |
false |
0 |
"false", "no", "off", "0" | Do not wrap text. Horizontal scrolling will appear if necessary |
"hint"
Sets a hint to the user of what can be entered in the control
Constant: Hint
Types: string
Examples
EditView {
hint = "User name",
}
editor := rui.NewEditView(session, rui.Params{
rui.Hint: "User name",
})
"max-length"
Sets the maximum number of characters that the user can enter
Constant: MaxLength
Types: int
, string
Values
int | string | Description |
---|---|---|
>= 0 |
>= "0" | Maximum number of characters |
"pattern"
Same as "edit-view-pattern"
Constant: Pattern
"readonly"
Controls whether the user can modify value or not. Default value is false
Constant: ReadOnly
Types: bool
, int
, string
Values
bool | int | string | Description |
---|---|---|---|
true |
1 |
"true", "yes", "on", "1" | User not able to modify the value |
false |
0 |
"false", "no", "off", "0" | Value can be modified |
"spellcheck"
Enable or disable spell checker. Available in SingleLineText
and MultiLineText
types of edit view. Default value is false
Constant: Spellcheck
Types: bool
, int
, string
Values
bool | int | string | Description |
---|---|---|---|
true |
1 |
"true", "yes", "on", "1" | Enable spell checker for text |
false |
0 |
"false", "no", "off", "0" | Disable spell checker for text |
"text"
Edit view text
Constant: Text
Types: string
Examples
EditView {
text = "Text value",
}
editor := rui.NewEditView(session, rui.Params{
rui.Text: "Text value",
})
"type"
Same as "edit-view-type"
Constant: Type
Events
"edit-text-changed"
Occur when edit view text has been changed
Constant: EditTextChangedEvent
General listener format:
func(editView rui.EditView, newText, oldText string)
where:
- editView - Interface of an edit view which generated this event
- newText - New edit view text
- oldText - Previous edit view text
Allowed listener formats:
func(editView rui.EditView, newText string)
func(newText, oldText string)
func(newText string)
func(editView rui.EditView)
func()
Related global functions
func AppendEditText(view View, subviewID string, text string)
Appends the text to the EditView
content. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned.
func EditViewByID(rootView View, id string, ids ...string) EditView
Returns the child EditView, path to which is specified using the arguments id, ids. Example: view := EditViewByID(rootView, "id1", "id2", "id3")
, view := EditViewByID(rootView, "id1/id2/id3")
. These two function calls are equivalent. If a View with this path is not found or View is not EditView, the function will return nil.
func GetCaretColor(view View, subviewID ...string) Color
Returns the color of the text input caret. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned.
func GetDataList(view View, subviewID ...string) []string
Returns the data list of an editor. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned.
func GetEditViewPattern(view View, subviewID ...string) string
Returns a value of the "pattern" property of EditView
. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned.
func GetEditViewType(view View, subviewID ...string) int
Returns a value of the "type" property of EditView
. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned.
func GetHint(view View, subviewID ...string) string
Returns a hint text of the subview. If the second argument (subviewID) is not specified or is an empty string then a text of the first argument (view) is returned.
func GetMaxLength(view View, subviewID ...string) int
Returns a maximal length of EditView
. If a maximal length is not limited then 0 is returned If the second argument (subviewID) is not specified or is an empty string then a value of the first argument (view) is returned.
func GetText(view View, subviewID ...string) string
Returns a text of the EditView
subview. If the second argument (subviewID) is not specified or is an empty string then a text of the first argument (view) is returned.
func GetTextChangedListeners(view View, subviewID ...string) []func(EditView, string, string)
Returns the TextChangedListener
list of an EditView
or MultiLineEditView
subview. If there are no listeners then the empty list is returned If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned.
func IsEditViewWrap(view View, subviewID ...string) bool
Returns a value of the "edit-wrap" property of MultiLineEditView
. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned.
func IsReadOnly(view View, subviewID ...string) bool
Returns the true if a EditView
works in read only mode. If the second argument (subviewID) is not specified or is an empty string then a value of the first argument (view) is returned.
func IsSpellcheck(view View, subviewID ...string) bool
Returns a value of the "spellcheck" property of EditView
. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned.