Why not simply do like gui.CaretManager:
        window.addEventListener("focus", showLocalCaret, false);
And why is the handler never removed, e.g. in endEditing? Or should this subscription perhaps not already be done in init() (and removed in destroy)?