From bd1a2ef7a3b778eda1e57bb02189c86d08df7f68 Mon Sep 17 00:00:00 2001 From: Jakub Sobon Date: Tue, 24 Nov 2020 19:48:35 -0500 Subject: [PATCH] Improving comments. --- container/container.go | 5 +++-- container/container_test.go | 2 -- container/focus.go | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/container/container.go b/container/container.go index 242f8e8..adb147d 100644 --- a/container/container.go +++ b/container/container.go @@ -123,7 +123,8 @@ func (c *Container) hasWidget() bool { } // isLeaf determines if this container is a leaf container in the binary tree of containers. -// Only leaf containers are guaranteed to be "visible" on the screen. +// Only leaf containers are guaranteed to be "visible" on the screen, because +// they are on the top of other non-leaf containers. func (c *Container) isLeaf() bool { return c.first == nil && c.second == nil } @@ -331,7 +332,7 @@ func (c *Container) prepareEvTargets(ev terminalapi.Event) (func() error, error) // Update the focused container based on the pressed key. // Done after collecting "targets" above. If the key changes which - // widget is focused, they key press itself should go to the widget + // container is focused, they key press itself should go to the widget // that was focused when the key was pressed. c.updateFocusFromKeyboard(ev.(*terminalapi.Keyboard)) return func() error { diff --git a/container/container_test.go b/container/container_test.go index f584c7e..6ee2b21 100644 --- a/container/container_test.go +++ b/container/container_test.go @@ -1548,7 +1548,6 @@ func TestMouse(t *testing.T) { testcanvas.MustNew(image.Rect(25, 0, 50, 20)), &widgetapi.Meta{}, widgetapi.Options{WantKeyboard: widgetapi.KeyScopeFocused}, - &terminalapi.Keyboard{}, ) return ft }, @@ -1592,7 +1591,6 @@ func TestMouse(t *testing.T) { testcanvas.MustNew(image.Rect(25, 0, 50, 20)), &widgetapi.Meta{Focused: true}, widgetapi.Options{WantKeyboard: widgetapi.KeyScopeFocused}, - &terminalapi.Keyboard{}, ) return ft }, diff --git a/container/focus.go b/container/focus.go index 1e8c1f9..a06f959 100644 --- a/container/focus.go +++ b/container/focus.go @@ -114,9 +114,8 @@ func (ft *focusTracker) next() { if nextCont == nil && firstCont != nil { // If the traversal finishes without finding the next container, move // focus back to the first container. - nextCont = firstCont - } - if nextCont != nil { + ft.setActive(firstCont) + } else if nextCont != nil { ft.setActive(nextCont) } }