Open ArthurD opened 3 years ago
After a lot of testing I personally think it's the limitations of the Electron itself. No one develop Electron as a standalone menubar app framework. So there are a lot of edge cases when it just don't work as you want unfortunately. For the best menubar experience the only option is to write it natively (but you can use Flutter for example, because it allows you to customize native code fully).
Description
My overarching goal is an app that is a "pure" menubar, targeting specifically macOS users, with the purpose being to show at-a-glance data in the menubar along with additional detail & quick "controls" when the app is open. I want it to function similar to most macOS menubar apps (ie 1Password) -- when focus is lost, the window should hide completely.
The 'Tips' section of the documentation specifies the following:
Steps to Reproduce the Problem
mb.on('focus-lost', () => { mb.window.hide(); });
Expected Behaviour
After closing the app via clicking outside of it [ie loss of focus], any future click on the app in the macOS menubar should re-activate & display the app/window.
Actual Behaviour
After closing the app via clicking outside of it [ie loss of focus], any future click on the app in the macOS menubar will intermittently (seems to toggle/alternate) have no effect / be a no-op click (window does not display). Clicking it a second time opens the window.
Specifications
Other information
It appears that using the following code, instead of the code above, actually causes the behavior to be as expected -- ie it resolves the issue -- so maybe this "issue" can just be 'fixed' via simply updating the documentation, I'm not sure.
mb.on('focus-lost', () => { mb.hideWindow(); });
If nothing else, I'd like to understand why this works & the approach that I tried initially does not; and if there is a way to make my initial approach work I'd love to hear & learn/understand it (ie do I need to call/init the window again somehow, or listen for menubar click manually & call show(), or similar). :)
Thank you very much; this is a fantastic project and I very much appreciate all the work that has gone into it! It's really quite nice -- thank you! :)