Is there a way to detect when tracking has started on the menu bar, including on menu extras? I have a window that I want to have behave like a menu, so it needs to be hidden when any other menu is displayed.
Related
I know I can "auto hide menu bar" in system preferences, however, what I like to do is hide items like this repository.
https://github.com/dwarvesf/hidden
This repository can hide items on right, but I wonder if I can hide left items (which are application menus).
Any idea is appreciated.
As for application menus on the left, those can't be hidden, I'm pretty sure.
Applications often have the option to enable or disable their menu bar helper app in the main preferences. If that doesn't help, e.g. if it's a full-fledged menu bar app, not just a helper, then to my knowledge the only solutions are Hidden Bar, which you mentioned, and Bartender.
I'm using the latter, and it does a very fine job. You have four options in Bartender's preferences:
Show (default macOS behavior)
Hide (menulet will be hidden in a special Bartender secondary menu bar, accessible via the triple-bullet icon ··· on the far right)
Always show (menulet will be visible in the main macOS menu bar as well as the secondary Bartender menu bar at the same screen position)
Always hide (menulet will be completely hidden)
Some older menulets seem to switch their position occasionally, e.g. after wake-from-sleep, and Bartender isn't yet able to fix the position of BitBar instances. But for the vast majority of menu bar apps and helpers it will work just fine.
I have a Mac application of type agent (LSUIElement is true).
When app is executed, app icon is shown in top menu bar. On clicking the app icon in menu bar, menu items (NSMenuItem) are displayed.
Please find below my observations on following two scenarios:
App is executed without assigning tooltip to menu items:
While navigating using keyboard, VoiceOver focus remains on menu item on which there is a keyboard focus.
This is working as expected.
App is executed after assigning tooltip to menu items (using setTooltip method):
While navigating through menu items using keyboard, suddenly VoiceOver focus is shifted to some other UI element on screen (e.g. Finder window, Safari window, etc) or VoiceOver focus does not move with keyboard focus.
I observed that, this happens when keyboard focus is kept on a menu item for some time (e.g. around 4-5 seconds) before navigating to other menu item.
This is not working as expected.
Ideally, VoiceOver focus should move with keyboard focus even if tooltip is assigned to menu items.
Can anyone please tell me how to fix this.
I have a macOS app that has a main menu in the menu bar (not an NSStatusItem). I would like this main menu to be visible when one of the app's windows is focused. However, I do not want this window to have a dock icon.
When I set LSUIElement to true, I notice that the menu bar never appears.
I have a feeling LSUIElement breaks the menu bar completely. Is there an alternative approach to giving an app menu bar menus without having a dock icon?
I'm on 10.14.3. What's strange is others seem to have success creating a menu bar in the app. But no matter how many times I focus my app, the menu bar does not appear.
setActivationPolcy(...) seems to prevent the main menu from appearing entirely. LSUIElement does not show the menu either.
I have a application with 2 windows (think like Twitter Timeline and mentions). For now I have been having the menus "Timeline ⌘1" and "Mentions ⌘2" in the "File" menu but this is kind of wrong. So I moved them to the "Windows" menu just by drag and drop.
When I open the application everything is nice, I can see both menu items unter the "Windows" menu. But then when I close for example the Mentions window the menu Item "Mentions ⌘2" disappears and I am not able to open this window anymore.
I have had a look at other applications and most of them have their Menu items to show the windows in the "Windows" menu and they don't disappear either after closing the windows. I am aware of the fact that Cocoa does soma magic with the "Window" menu item and it is quite ok in doing so (because I open some other windows which need to appear and disappear from there), but how can I make those two items kind of static so they don't disappear?
I finally found an answer, in order for them to not be handled by the Windows menu you need to call
[timelineViewWindow setExcludedFromWindowsMenu:YES];
[mentionsViewWindow setExcludedFromWindowsMenu:YES];
and after that add the Menu items to the Windows menu and they will not disappear anymore.
XCode works in mysterious ways (at least to me).
I simply want to create a Preference pane in my app. When I run my app, the stock menu bar comes up (Apple, MyApp, File, Edit...) and the "Preferences" menu item is grayed out. It makes sense since I haven't started playing with it.
How on earth do I add/remove/activate/inactivate menu items? I'm not talking about adding anything new, simply using what should be there.
Thanks in advance.
NSMenu has "Auto Enable Items" enabled by default. That means if the menu item does not have it's action message hooked up, it will appear grayed out. So in your case, you would simply set the Preferences menu item's "Sent Action" to whatever action shows your preferences window. This can be hooked to some sort of showPreferencesWindow: method of your AppDelegate, or directly to the showWindow: method of a window controller.
To dynamically enable/disable menu items the best way is to implement the NSUserInterfaceItemValidation protocol which is excellently documented here
Edit: Your app's menu bar items live in the MainMenu.xib file. The menu bar appears as a "Main Menu" object on the left hand side (if you're using Xcode 4) Simply click on the items to modify them, and you can Ctrl+drag connections to and from them like any UI object.