From c458eb30f02f9bc1f126551e057d38d04b2b509f Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Tue, 5 Dec 2023 09:38:52 -0600 Subject: [PATCH] widget/material: add missing Update calls Without the updates, the switch and radiobutton would use stale state for layout. Signed-off-by: Elias Naur --- widget/material/radiobutton.go | 1 + widget/material/switch.go | 1 + 2 files changed, 2 insertions(+) diff --git a/widget/material/radiobutton.go b/widget/material/radiobutton.go index 97ff6b90..499c79f7 100644 --- a/widget/material/radiobutton.go +++ b/widget/material/radiobutton.go @@ -38,6 +38,7 @@ func RadioButton(th *Theme, group *widget.Enum, key, label string) RadioButtonSt // Layout updates enum and displays the radio button. func (r RadioButtonStyle) Layout(gtx layout.Context) layout.Dimensions { + r.Group.Update(gtx) hovered, hovering := r.Group.Hovered() focus, focused := r.Group.Focused() return r.Group.Layout(gtx, r.Key, func(gtx layout.Context) layout.Dimensions { diff --git a/widget/material/switch.go b/widget/material/switch.go index 62472242..1c21581e 100644 --- a/widget/material/switch.go +++ b/widget/material/switch.go @@ -39,6 +39,7 @@ func Switch(th *Theme, swtch *widget.Bool, description string) SwitchStyle { // Layout updates the switch and displays it. func (s SwitchStyle) Layout(gtx layout.Context) layout.Dimensions { + s.Switch.Update(gtx) trackWidth := gtx.Dp(36) trackHeight := gtx.Dp(16) thumbSize := gtx.Dp(20)