From 79210ae8c9d92671fe50acf41aab6e774606264a Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Wed, 6 Oct 2021 22:19:43 -0700 Subject: [PATCH] Add Supervisor.CloseActiveWindow() --- window_manager.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/window_manager.go b/window_manager.go index 14df10b..a3c4dd1 100644 --- a/window_manager.go +++ b/window_manager.go @@ -179,6 +179,17 @@ func (s *Supervisor) CloseAllWindows() int { return i } +// CloseActiveWindow closes the topmost active window. +func (s *Supervisor) CloseActiveWindow() bool { + var node = s.winFocus + if node != nil { + node.window.Hide() + s.winFocus = node.next + return true + } + return false +} + // presentWindows draws the windows from bottom to top. func (s *Supervisor) presentWindows(e render.Engine) { item := s.winBottom