ViewsContainer
Table of contents
An interface that allows manipulation of child views. It is the base for other containers like ListLayout
, GridLayout
, StackLayout
, etc. and it is not used on its own
Interface description
Inherit methods, properties and events from ParentView
, View
Append(view View)
Appends a view to the end of the list of a view children
Insert(view View, index int)
Inserts a view to the "index" position in the list of a view children
RemoveView(index int) View
Removes a view from the list of a view children and return it
ViewIndex(view View) int
Returns the index of view, -1 if view has not been found
Properties
"content"
An array of child views.
Constant: Content
Types: View
, []View
, string
, []string
, []any
containing elements of View
, string
Internal type is []View
, other types converted to it during assignment
Conversion rules
View
- converted to []View
containing one element
[]View
- nil-elements are prohibited, if the array contains nil, then the property will not be set, and the Set
function will return false and an error message will be written to the log
string
- if the string is a text representation of the View
, then the corresponding view is created, otherwise a TextView
is created, to which the given string is passed as a text. Then a []View
is created containing the resulting view
[]string
- each element of an array is converted to View
as described above
[]any
- this array must contain only View
and a string
. Each string
element is converted to a view as described above. If array contains invalid values, the "content" property will not be set, and the Set
function will return false
and an error message will be written to the log
Examples
ListLayout {
width = 100%,
content = [
"Item 1",
ImageView {
src = "search.png",
},
EditView {
hint = "Enter name or description",
},
],
}
list := rui.NewListLayout(session, rui.Params{
rui.Width: rui.Percent(100),
rui.Content: []string{
"Item 1",
"ImageView { src = \"search.png\",}",
"EditView { hint = \"Enter name or description\",}",
},
})
list := rui.NewListLayout(session, rui.Params{
rui.Width: rui.Percent(100),
rui.Content: []rui.View{
rui.NewTextView(session, rui.Params{
rui.Text: "Item 1",
}),
rui.NewImageView(session, rui.Params{
rui.Source: "search.png",
}),
rui.NewEditView(session, rui.Params{
rui.Hint: "Enter name or description",
}),
},
})
"disabled"
Controls whether the view can receive focus and which style to use. Default value is false
Constant: Disabled
Types: bool
, int
, string
Values
bool | int | string | Description |
---|---|---|---|
true |
1 |
"true", "yes", "on", "1" | View can't receive focus and "style-disabled" style will be used by the view |
false |
0 |
"false", "no", "off", "0" | View can receive focus and "style" style will be used by the view |
Related global functions
func AppendView(rootView View, containerID string, view View) bool
Appends view to the end of container's children list
func InsertView(rootView View, containerID string, view View, index int) bool
Inserts view at the "index" position of container's children list
func RemoveView(rootView View, containerID string, index int) View
Removes view from container's children list using index
func ViewsContainerByID(rootView View, id string) ViewsContainer
Return a ViewsContainer
with id equal to the argument of the function or nil if there is no such View or View is not a ViewsContainer