From 6d6629d3c0734f043b908be238f092cda523a995 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sun, 12 Apr 2020 16:49:21 -0700 Subject: [PATCH] Add helper function IsPointInWindow --- supervisor.go | 2 +- window_manager.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/supervisor.go b/supervisor.go index b00690a..00b8d31 100644 --- a/supervisor.go +++ b/supervisor.go @@ -173,7 +173,7 @@ func (s *Supervisor) Loop(ev *event.State) error { if err == ErrStopPropagation || handled { // A widget in the active window has accepted an event. Do not pass // the event also to lower widgets. - return nil + return err } // Run events for the other widgets not in a managed window. diff --git a/window_manager.go b/window_manager.go index 2bbeab5..e3cfeea 100644 --- a/window_manager.go +++ b/window_manager.go @@ -151,6 +151,19 @@ func (s *Supervisor) FocusWindow(win *Window) error { return nil } +// IsPointInWindow returns whether the given Point overlaps with a window managed +// by the Supervisor. +func (s *Supervisor) IsPointInWindow(point render.Point) bool { + node := s.winFocus + for node != nil { + if point.Inside(AbsoluteRect(node.window)) { + return true + } + node = node.next + } + return false +} + // presentWindows draws the windows from bottom to top. func (s *Supervisor) presentWindows(e render.Engine) { item := s.winBottom