Skip to content

Commit

Permalink
Merge pull request #4044 from mbaklor/check-text
Browse files Browse the repository at this point in the history
Add SetText method to Check widget
  • Loading branch information
andydotxyz authored Jul 13, 2023
2 parents d4b95e1 + f1144c7 commit c35e8f0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions widget/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,14 @@ func (c *Check) TypedRune(r rune) {
// TypedKey receives key input events when the Check is focused.
func (c *Check) TypedKey(key *fyne.KeyEvent) {}

// SetText sets the text of the Check
//
// Since: 2.4
func (c *Check) SetText(text string) {
c.Text = text
c.Refresh()
}

// Unbind disconnects any configured data source from this Check.
// The current value will remain at the last value of the data source.
//
Expand Down
7 changes: 7 additions & 0 deletions widget/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,10 @@ func TestNewCheckWithData(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, false, v)
}

func TestCheck_SetText(t *testing.T) {
check := &widget.Check{Text: "Test"}
check.SetText("New")

assert.Equal(t, "New", check.Text)
}

0 comments on commit c35e8f0

Please sign in to comment.