On the very top of my Mac, there is a bar which has my battery percentage, the date and time, the volume, etc. There is also a dropbox folder. How can I create something that gets thrown up there? I'd like to put a few shortcuts in that menu bar. Is there a way to do it?
That bar is the equivalent to the system notification bar on Windows. You want to place your shortcuts on the dock (normally located at the bottom of your screen). You do this by drag and dropping.
While OS X provides no centralized tool to enable or configure menu extras, some of them can be rearranged and dragged off the menubar while depressing the ⌘ key. Also, all Apple-supplied menu extras can be found in the folder /System/Library/CoreServices/Menu Extras.
From Wikipedia
However, if you are determined to put your shortcuts on the bar, here is how to create menu extras
Alternatively, there are some free apps already created for this purpose. HimmelBar - Free, XMenu - Free, and MoofMenu - $5
You want to use the NSStatusBarItem class (see also the NSStatusBar class which represents the menu bar itself.)
Note that icons/menus created with this API do not "mix and match" with the OS-provided ones, but rather are aligned to the left of them and cannot be dragged by the user. Still, it's good enough for most uses.
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.
Is there a way to get vscode show navigation menu i.e Code|File|Edit|... and the project name in a full screen mode on MAC. It's almost impossible to see the name of the project when having multiple instances of code open in full screen mode.
v1.42 has a new option that may help:
Controls if native full-screen should be used on macOS.
Disable this option to prevent macOS from creating a new space when going full-screen.
"window.nativeFullScreen": true,
I believe this is not what the full screen mode is made for. If you go full screen you are supposed to work almost exclusively in that application (only occasionally switching to other apps like mail, e.g. via command+tab). You can always have the menu bar (and the window title) appear when you move the mouse pointer to the top of the screen, however.
The name of the project is visible in the file explorer.
In this example, the project name (i.e. root folder) is testgit
You can always quickly show the file explorer using the keyboard shortcut Shift-Cmd-E.
For one of my software, I might need to have to add some objects that could have the same behavior as any of object already present (apps/stack etc.), having a contextual menu.
Is it some how possible ?
Thx.
Not possible. That's the domain of applications, files and folders, configured by the user. You do, however, have the ability to add a menu to your own application whose icon appears in the Dock.
You might consider menu extras, but those come with their own set of problems. One in particular is the OS making them disappear when space in the menu bar becomes tight.
I've removed the menu from my cocoa app, all of the interaction should happen from within a status item, that links to a menu, that links to different NSPanels. But this seems to have removed the ability to ⌘C or ⌘V within a NSTextField. Is there a way to add this back without having to have a standard menu included with my app?
Even if your app is a faceless background app, so it never shows a menu bar, you should still have a full main menu because that's what provides all of the default actions (and enables the user to redefine the key commands if they so choose). If you remove the main menu, you have to reimplement everything in it, including anything Apple adds in the future, in code.
And I'd especially warn you against trying to handle keyboard shortcuts yourself. That's damned tricky. A lot of applications get it wrong, causing us Dvorak users (among others) to curse their developers.
I assume you can just implement the actions originally connected to the menu items in a keyDown event. Check out this page for details: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/HandlingKeyEvents/HandlingKeyEvents.html
Just have it respond to cmd-v with paste:, and cmd-C with copy:
Edit: Though I have to agree with Peter, you really should have a main menu...
You all know the menu bar (or better said NSStatusBar) in Mac OS X.
There are some items which I can move and other which not.
I would like to be able to drag the NSStatusItem of my app.
Any idea how to implement this?
Although NSStatusItems appear near Apple's internal "menu extras", they are distinct and behave differently. It would be nice if Apple unified the items that can appear in the right-hand area of the menu bar, but for now the section is split into distinct "apple internal" (on the right), and "app-provided (NSStatusItem)" on the left.
You can visualize the distinction by putting your computer into screen capture mode (cmd-shift-4), and pressing the space bar to switch to "capture whole window". When you hover over Apple's menu icons, you'll see that they all live in a single window. This explains their ability to be easily managed and dragged about. Hovering over the other items reveals that each NSStatusItem is in fact living in a single window of its own (which happens to be owned by the application that installed it).
It's best to stick with NSStatusItem even though you can't drag them. It's a shortcoming from Apple which most users will understand, even if it's annoying. Emphasizing the positive tradeoffs of offering a more stable application for the long term will usually soften the opinions of your customers (or managers?) who are pushing for the draggability.
You'll have to use NSMenuExtra, not NSStatusItem, and make the menu item a bundle running inside the SystemUIServer process, not your own app. You'll also need code like that supplied by MenuCracker to get this to work.
NSMenuExtra is undocumented and unsupported, and therefore considered a "hack".
My guess for there being two APIs in the first place: a menu extra crashing (or memory leaking) means the entire SystemUIServer process crashing or memory leaking — including other third party modules as well as system-supplied ones. With a status item, on the other hand, such a problem would only affect your own code.
As of macOS Sierra 10.12 http://www.macworld.co.uk/how-to/mac-software/7-sierra-menu-bar-tips-how-use-mac-menu-bar-in-macos-sierra-3649163/
Third-party apps sometimes install as menu extras, have controls that exist in the menu bar, or can be relaunched as faceless apps despite not initially being so. As of macOS Sierra, these menu extras can be rearranged just like native ones. (This wasn't the case through to OS X El Capitan.)