From 685bf6da76c251945b06b5dfeb68e35f620ad35f Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 18 Oct 2019 14:55:27 +0200 Subject: [PATCH] Added GetFrontPage() to Pages. Resolves #355 --- pages.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pages.go b/pages.go index 85ca444..155da73 100644 --- a/pages.go +++ b/pages.go @@ -226,6 +226,17 @@ func (p *Pages) SendToBack(name string) *Pages { return p } +// GetFrontPage returns the front-most visible page. If there are no visible +// pages, ("", nil) is returned. +func (p *Pages) GetFrontPage() (name string, item Primitive) { + for index := len(p.pages) - 1; index >= 0; index-- { + if p.pages[index].Visible { + return p.pages[index].Name, p.pages[index].Item + } + } + return +} + // HasFocus returns whether or not this primitive has focus. func (p *Pages) HasFocus() bool { for _, page := range p.pages {