From 85c09dabf1d588011e746b2ebe873319252bac70 Mon Sep 17 00:00:00 2001 From: Leandro Dorileo Date: Tue, 11 Sep 2018 16:58:39 -0700 Subject: [PATCH] NextControl also considers parent's visibility Whenever running through NextControl() also exclude those controls which parents are also non visible. Signed-off-by: Leandro Dorileo --- ctrlutil.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ctrlutil.go b/ctrlutil.go index 273a74e..a38f192 100644 --- a/ctrlutil.go +++ b/ctrlutil.go @@ -213,7 +213,21 @@ func getLinearControlList(parent Control, fn func(Control) bool) []Control { // that has tab-stop feature on. Used by library when processing TAB key func NextControl(parent Control, curr Control, next bool) Control { fnTab := func(c Control) bool { - return c.TabStop() && c.Visible() && c.Enabled() + isVisible := func() bool { + ctrl := c.Parent() + + for ctrl != nil { + if !ctrl.Visible() { + return false + } + + ctrl = ctrl.Parent() + } + + return c.Visible() + } + + return c.TabStop() && isVisible() && c.Enabled() } linear := getLinearControlList(parent, fnTab)