Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppTabs OnSelected fires a lot of times on Disable and Enable #5449

Open
2 tasks done
massiveits opened this issue Jan 22, 2025 · 0 comments
Open
2 tasks done

AppTabs OnSelected fires a lot of times on Disable and Enable #5449

massiveits opened this issue Jan 22, 2025 · 0 comments
Labels
unverified A bug that has been reported but not verified

Comments

@massiveits
Copy link

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

Upon disabling the AppTabs and then re-enable it, the OnSelected event keeps firing.

How to reproduce

Run the code below and click on ony of the tabs

Screenshots

No response

Example code

package main

import (
	"strconv"
	"time"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/layout"
)

func main() {
	myApp := app.New()
	myWindow := myApp.NewWindow("AppTabs Example")
	tabs := []*container.TabItem{}

	for i := 0; i < 5; i++ {
		tabs = append(tabs, container.NewTabItem("tab "+strconv.Itoa(i), layout.NewSpacer()))
	}

	appTabs := container.NewAppTabs(tabs...)

	appTabs.OnSelected = func(tab *container.TabItem) {
		for _, v := range appTabs.Items {
			appTabs.DisableItem(v)
		}
		println(tab.Text)
		time.Sleep(1 * time.Second)
		for _, v := range appTabs.Items {
			appTabs.EnableItem(v)
		}
	}

	myWindow.SetContent(appTabs)
	myWindow.Resize(fyne.NewSize(400, 300))
	myWindow.ShowAndRun()
}

Clicking on any of the tabs will output something like:

tab 4
tab 4
tab 3
tab 4
tab 2
tab 4
tab 3
tab 4
tab 2
tab 4
tab 3
tab 4
tab 2
tab 4
tab 3
tab 4
tab 2
tab 4
tab 3
tab 4
tab 2
tab 4
tab 3
...

Fyne version

2.5.2

Go compiler version

1.23.2

Operating system and version

Windows 11

Additional Information

No response

@massiveits massiveits added the unverified A bug that has been reported but not verified label Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified A bug that has been reported but not verified
Projects
None yet
Development

No branches or pull requests

1 participant