Callback for frontmost document changed

Hello, is there any callback for when the frontmost document has changed (with Option+Tab, for instance)? I can’t find anything that works.

That would be the same code that I just posted here: Callback when export dialog open - #4 by GeorgSeifert