I need to react everytime my panda window gets focus. At the moment I’m listening to ‘window-event’, but that gets fired far to often - e.g. also when the window loses focus.
‘PandaRestarted’ is also not suitable, since this is only fired when the window was previously minimized and is maximized again.
Is there a special event I could listen to to catch only the ‘OnFocus’ events?
thanks in advance,
p.s.: is there a list somewhere with all panda events?
You can put this somewhere:
That will print out any events that might occur on the console.
If you want to see if there’s an OnFocus event, just put that code somewhere, focus the window, and see if any events were fired.
Responding to window-event is correct, but you should do your stuff only if window.getProperties().isForeground() is true.
Thanks for your answers.
I called toggleVerbose(), turns out ‘window-event’ is indeed the only event that is sent onFocus.
Oddly, checking for window.getProperties().hasForeground() is true even when I alt-tab to another window (that is fullscreen), so I still get some false positives.
p.s.: is it just me or does the panda website have some serious problems today? I get a “Redirect Loop” error all the time…
Don’t check for hasForeground, but check for getForeground.
No, there’s still maintenance going on.
Thanks, works like a charm!