From 802f92be4eea6c1c3343a486cf26f7654f8c9b62 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Wed, 18 Oct 2023 16:49:21 +0100 Subject: [PATCH] Ensure segments are up to date on first draw Fixes #4312 --- widget/entry.go | 1 + widget/entry_password_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 widget/entry_password_test.go diff --git a/widget/entry.go b/widget/entry.go index a18da8d5b2..feaa286d06 100644 --- a/widget/entry.go +++ b/widget/entry.go @@ -200,6 +200,7 @@ func (e *Entry) CreateRenderer() fyne.WidgetRenderer { objects = append(objects, e.ActionItem) } + e.syncSegments() return &entryRenderer{box, border, e.scroll, objects, e} } diff --git a/widget/entry_password_test.go b/widget/entry_password_test.go new file mode 100644 index 0000000000..10742737fa --- /dev/null +++ b/widget/entry_password_test.go @@ -0,0 +1,25 @@ +package widget_test + +import ( + "testing" + + "fyne.io/fyne/v2" + "fyne.io/fyne/v2/canvas" + "fyne.io/fyne/v2/container" + "fyne.io/fyne/v2/test" + "fyne.io/fyne/v2/widget" + "github.com/stretchr/testify/assert" +) + +func TestNewPasswordEntry(t *testing.T) { + p := widget.NewPasswordEntry() + p.Text = "visible" + r := test.WidgetRenderer(p) + + cont := r.Objects()[2].(*container.Scroll).Content.(fyne.Widget) + r = test.WidgetRenderer(cont) + rich := r.Objects()[1].(*widget.RichText) + r = test.WidgetRenderer(rich) + + assert.Equal(t, "•••••••", r.Objects()[0].(*canvas.Text).Text) +}