Added a toggle button and lamp pattern
This commit is contained in:
@@ -79,6 +79,20 @@ func (entity *entity) propagate (callback func (*entity) bool) bool {
|
||||
return callback(entity)
|
||||
}
|
||||
|
||||
|
||||
func (entity *entity) propagateAlt (callback func (*entity) bool) bool {
|
||||
if !callback(entity) {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, child := range entity.children {
|
||||
if !child.propagate(callback) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
func (entity *entity) childAt (point image.Point) *entity {
|
||||
for _, child := range entity.children {
|
||||
if point.In(child.bounds) {
|
||||
|
||||
@@ -76,7 +76,7 @@ func (system *system) focus (entity *entity) {
|
||||
func (system *system) focusNext () {
|
||||
found := system.focused == nil
|
||||
focused := false
|
||||
system.propagate (func (entity *entity) bool {
|
||||
system.propagateAlt (func (entity *entity) bool {
|
||||
if found {
|
||||
// looking for the next element to select
|
||||
child, ok := entity.element.(tomo.Focusable)
|
||||
@@ -118,6 +118,11 @@ func (system *system) propagate (callback func (*entity) bool) {
|
||||
system.child.propagate(callback)
|
||||
}
|
||||
|
||||
func (system *system) propagateAlt (callback func (*entity) bool) {
|
||||
if system.child == nil { return }
|
||||
system.child.propagateAlt(callback)
|
||||
}
|
||||
|
||||
func (system *system) childAt (point image.Point) *entity {
|
||||
if system.child == nil { return nil }
|
||||
return system.child.childAt(point)
|
||||
|
||||
Reference in New Issue
Block a user