Skip to content

How to add slice of widget to a Frame ? #1244

Closed Answered by kkoreilly
heejit asked this question in Q&A
Discussion options

You must be logged in to vote

The issue is that you need to re-fetch vData in each inner closure function inside of AddAt, since it is still the same function from before with a stale closure variable as long as the index is the same. So if you do something like this in your Maker, you shouldn't need the manual Update or DeleteChildren between clearing and adding:

	for i := range this.noteDataAry {
		tree.AddAt(p, strconv.Itoa(i), func(w *Card) {
			w.Updater(func() {
				vData := this.noteDataAry[i]
				w.SetHeading(vData.Name)
				w.SetSubHeading(fmt.Sprintf("ID=%d | LU-Time=%s", vData.Id, vData.Time))
				w.SetData(vData.Id)
			})
			w.OnClick(func(e events.Event) {
				vData := this.noteDataAry[i]
				this.ShowNote(

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@kkoreilly
Comment options

@heejit
Comment options

@heejit
Comment options

@kkoreilly
Comment options

Answer selected by heejit
@heejit
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants