Element methods are now more consistent and have less bool flags

Still need to update most examples...
This commit is contained in:
2023-04-18 13:14:10 -04:00
parent a2b1ac0c73
commit 14080b1f88
17 changed files with 209 additions and 653 deletions

View File

@@ -29,7 +29,7 @@ type List struct {
onScrollBoundsChange func ()
}
func NewList (columns int, children ...tomo.Selectable) (element *List) {
func NewList (columns int, children ...tomo.Element) (element *List) {
if columns < 1 { columns = 1 }
element = &List { selected: -1 }
element.scratch = make(map[tomo.Element] scratchEntry)
@@ -152,6 +152,15 @@ func (element *List) DisownAll () {
element.entity.InvalidateLayout()
}
func (element *List) Child (index int) tomo.Element {
if index < 0 || index >= element.entity.CountChildren() { return nil }
return element.entity.Child(index)
}
func (element *List) CountChildren () int {
return element.entity.CountChildren()
}
func (element *List) HandleChildMouseDown (x, y int, button input.Button, child tomo.Element) {
if child, ok := child.(tomo.Selectable); ok {
index := element.entity.IndexOf(child)