`PollEvent()` returns `nil` when screen is suspended
rivo opened this issue · 3 comments
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()
}
This was an unintentional change, and is a rightly a bug.
Thank you!
Thanks so much for fixing this! ❤️