From 24c4d68b0cda832dc5d2ee8c009e3c4ce1a8505b Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Sun, 3 Apr 2022 17:31:46 +0200 Subject: [PATCH] fixed RemoveViews again --- tests/screen_test.go | 4 ++-- views/layout_flow.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/screen_test.go b/tests/screen_test.go index 6c8ec77..45820da 100644 --- a/tests/screen_test.go +++ b/tests/screen_test.go @@ -62,8 +62,8 @@ func TestScrollView(t *testing.T) { } screen.MouseClicked = func(event *tui.MouseEvent) (consumed bool) { - textViews[0].(*views.TextView).Text = fmt.Sprintf("mouse position: %d | %d", event.X, event.Y) - textViews[1].(*views.TextView).Text = fmt.Sprintf("mouse button: %d", event.Button) + //textViews[0].(*views.TextView).Text = fmt.Sprintf("mouse position: %d | %d", event.X, event.Y) + //textViews[1].(*views.TextView).Text = fmt.Sprintf("mouse button: %d", event.Button) if event.Button == tui.MouseWheelUp { scrollView.Scroll(-1, 0) diff --git a/views/layout_flow.go b/views/layout_flow.go index 7058f13..0751821 100644 --- a/views/layout_flow.go +++ b/views/layout_flow.go @@ -24,7 +24,7 @@ func NewFlowLayout(orientation tui.Orientation) *FlowLayout { } func (g *FlowLayout) Views() []tui.View { - return g.views[:] + return g.views } func (g *FlowLayout) AppendViews(v ...tui.View) { @@ -49,7 +49,11 @@ func (g *FlowLayout) removeView(v tui.View) { } func (g *FlowLayout) RemoveViews(v ...tui.View) { + views := make([]tui.View, 0, len(v)) for _, view := range v { + views = append(views, view) + } + for _, view := range views { g.removeView(view) } }