From ef51f38ab64f28b425355a51b01307f9c33c8990 Mon Sep 17 00:00:00 2001 From: Andrew D'Angelo Date: Sat, 23 Mar 2024 10:42:00 -0500 Subject: [PATCH 1/2] No break in SetFocused loop applies old focus after exiting --- flex.go | 1 + 1 file changed, 1 insertion(+) diff --git a/flex.go b/flex.go index 821a595..dd404ac 100644 --- a/flex.go +++ b/flex.go @@ -130,6 +130,7 @@ func (flex *Flex) SetFocused(comp Component) { if child.target == comp { flex.focused = &child flex.focused.Focus() + break } } } From 7010723ca32c592708e13840a0b0533c6c04eb67 Mon Sep 17 00:00:00 2001 From: Andrew D'Angelo Date: Fri, 19 Apr 2024 18:05:06 -0500 Subject: [PATCH 2/2] Set focused to pointer --- flex.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/flex.go b/flex.go index dd404ac..cbddbb3 100644 --- a/flex.go +++ b/flex.go @@ -126,9 +126,10 @@ func (flex *Flex) OnPasteEvent(event PasteEvent) bool { } func (flex *Flex) SetFocused(comp Component) { - for _, child := range flex.children { - if child.target == comp { - flex.focused = &child + for i := range flex.children { + childp := &flex.children[i] + if childp.target == comp { + flex.focused = childp flex.focused.Focus() break }