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

PollEvent() returns nil when screen is suspended #677

Closed
rivo opened this issue Jan 11, 2024 · 3 comments
Closed

PollEvent() returns nil when screen is suspended #677

rivo opened this issue Jan 11, 2024 · 3 comments

Comments

@rivo
Copy link
Contributor

rivo commented Jan 11, 2024

It seems that the behaviour of Screen.PollEvent() has changed with v2.7.0. Whereas before, PollEvent() blocked between a call to Screen.Suspend() and Screen.Resume(), now it returns with a nil value.

Was this change intended? The documentation says that PollEvent() "will return nil if the Screen is finalized" and I would not consider a suspended screen finalized. So I would expect PollEvent() to block until the next event is received, as it was before v2.7.0.

If this change was intended, I think it should be documented ("if the Screen is finalized or suspended"). Then (at least in tview) I would have to keep track of suspended states whereas now, I use the nil value solely to determine if a screen has been finalized. Personally, though, I would like this to go back to how it was before (i.e. PollEvent() blocks until the next event from an active screen).

Here's some code to reproduce this:

func main() {
	s, _ := tcell.NewScreen()
	s.Init()

	s.PollEvent()

	s.Suspend()
	s.PollEvent() // This returns with nil in v2.7.0. It blocks in v2.6.1.
	s.Resume()

	s.PollEvent()

	s.Fini()
}
@gdamore
Copy link
Owner

gdamore commented Feb 16, 2024

This was an unintentional change, and is a rightly a bug.

@rivo
Copy link
Contributor Author

rivo commented Feb 25, 2024

Thank you!

@ilikeorangutans
Copy link

Thanks so much for fixing this! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants