Customize the Apple Menu - macos

How to customize the Apple menu? What SDKs should I study, etc.? I want to insert a menu item:

Apple Menu Specific
This AskDifferent question addresses removing an item from the Apple menu. Seems you could use the same technique to add an item. Just be sure to make a backup of any system files you edit.
The following posts recommend similar solutions but are a bit dated. The system file path appears to be the same, however.
Hide unwanted Apple menu items
Remove the 'Get Mac OS X Software' menu item
Also mentioned in the AskDifferent quesiton, FruitMenu allows for menu customization. However, there's no support for the more current versions of OS X.
Version 3.8.4 released Mar 3, 2011
Requires Mac OS X 10.5.8 or Mac OS X 10.6.x; Rosetta
Compatible with Mac OS X 10.6 Snow Leopard.
OS X Menu Item Tutorials
Creating a Standalone StatusItem Menu 1
This tutorial will show you how to create a StatusItem menu that will be available to all applications in the menu bar.
When you are done, you will have a simple menu that will appear on its own in the menubar as a "universal" background application, and will contain two menu items that let you enter a string into the Console and Quit itself. Note that you will need to code the functionality yourself for any menu item(s) you add or modify, but this will get you started.
Creating a Status Bar Application
This tutorial assumes you have a basic knowledge of Objective-C. In this tutorial, we will walk-through on how to create a status bar only application for the Mac OS X.
1 Mac Menu Bar Tutorial?

It is simply a folder named "Apple Menu Items" in the System Folder which you can manipulate in many ways. But don't rename it or move it out of the System Folder.
http://www.macoptions.com/os85/applemenu.html

Related

How to add Finder/Services menu items to own macOS contextual menu

When a file is right-clicked in the macOS Finder, a contextual menu like this shows up. It contains items at the bottom from macOS Services. I'm talking about services from third party such as (in this case) iTerm and Find Any File. How would I go about adding such items to a contextual menu in my own macOS app? Is there a documented API to do this?
I know this can be done, because it's implemented in at least one other application, see for example the following contextual menu in Find Any File:
macOS provides App Extensions for products to integrate with the OS. The programming guide lists the different extension points that can be utilised, along with a description of their purpose.
Based on the example you've provided, it may be the Finder Sync extension that you're looking for, as the documentation states for Finder Sync:
Badge local OS X folders to let users know the status of items that are remotely synced. You can also implement contextual menus to let users directly manage their synced content.

How to change the Mac OS X dock icon in a wxPython application

When a wx.App is launched through a script (i.e., not bundled with py2app) its icon in the dock is the standard Python rocket. Is it possible to customize that icon? It seems that in the past wx.TaskBarIcon did this (see http://wiki.wxpython.org/Custom%20Mac%20OsX%20Dock%20Bar%20Icon), but now it adds an icon to the menu bar.
I had the same issue and it seems there is a lack of documentation about this. I found several piece of information in different discussion threads.
You have to use the iconType argument of the wx.TaskBarIcon constructor. there are currently three possible values:
wx.TBI_CUSTOM_STATUSITEM: will create an icon in right part of the menu bar.
wx.TBI_DEFAULT_TYPE: default parameter, similar as TBI_DOCK for wxPython 3.0.
wx.TBI_DOCK: will replace the Python rocket with the selected icon
If you reuse the example from the wx official documentation, you just need to replace this line
wx.TaskBarIcon.__init__(self)
with this line
wx.TaskBarIcon.__init__(self, iconType=wx.TBI_DOCK)
The problem with this solution is that you have to choose to put the icon either in the menu bar either in the dock. It does not seem possible to put an icon in the both place while using only one instance of wx.TaskBarIcon.
Here are my current settings:
mac os X 10.11.5
wxPython 3.0.2.0
python 2.7.10

Qt5 OS X menubar empty menu-item not hidden

I'm using Qt5 on OS X 10.8 and I'm creating an application with a menu bar in Qt Creator. Placing items like Quit or Preferences in the application menu works by specifying the menuRole accordingly. However, since those items need to be placed in some menu and then get moved automatically by Qt into the application menu I end up with empty menu items.
According to this the empty items should be hidden but for me they are not.
What I have is this:
File
Preferences
<Separator>
Quit
Help
About
Preferences, Quit and About are correctly moved to the application menu. Unfortunately File and About are still shown. How can I make Qt hide them?
After going back to the project about 10 months and two minor Qt versions later, the problem is now gone. I just installed Qt 5.2 on OS X 10.9 and the app's menu is as expected.

64-bit replacement for [NSMenuItemCell menuView] and [NSMenuItemCell setMenuView]

What are the 64-bit replacements for the two methods -[NSMenuItemCell menuView] and -[NSMenuItemCell setMenuView:] of the NSMenuItemCell class?
How can I obtain the same results?
The NSMenuItemCell and NSMenuView have never been used to draw menus in any release version of Mac OS X. The following is an excerpt from the Mac OS X Developer Release Notes:
Notes specific to MacOS X Developer Preview 3
Menu
The implementation of menus has changed drastically; NSMenuView and
NSMenuItemCell are no longer used, -[NSMenu menuRepresentation] now
returns nil, and tear off menus are no longer available. For Developer
Preview 3, there is no support for menu item images. If there is no
text in the menu item, a placeholder text consisting of "< image >" or
"< image name >" will be inserted instead. Menu item state images are
not supported either and in their place the standard checkbox or dash
for on and mixed states are used.
(I'm not sure of the exact timeline of pre-Public beta Mac OS X, but for "Developer Preview 3", I'd guess we're talking around the late 1990s here).
For more info on how menus are currently implemented, see Application Menu and Pop-up List Programming Topics: How Menus Work
As 一二三 alluded to, you use NSMenu along with NSMenuItem to implement menus. In OS X 10.5 and greater, you can use custom NSView instances in NSMenuItems using the -setView: method.
To customise menu item drawing, you need to supply a custom view to NSMenuItem.

How do I add items to the Finder context menu in Mac OS X?

I'm in the process of porting a Windows application to OS X (we wrote it in Java so most of the code is portable), but what I'm currently unsure of is how to add context menu items in the Finder window when the user right clicks on an item (i.e. I wish to add some items to the the menu that has "Open" "Open with" , "Get Info", etc... when the user right clicks).
Most of the articles I've found deal specifically with Windows (I've searched for "context menus" and "shell extension", but I believe I may be searching the wrong terms), so I'm curious as to how to go about adding this in Mac or what literature I should be reading.
You may want to take a look at using Services. The Finder appends applicable Services to the end of its contextual menu and, depending on your needs, just fit the bill.
In each Library folder may be a "Contextual Menu Items" folder. Special plugin bundles placed in that folder will be loaded and may place items in contextual menus. Look in Menus.h for the entry points of these plugin bundles.
CMPluginExamineContext
CMPluginHandleSelection
CMPluginPostMenuCleanup
From what I have read, Contextual Menu Items are not supported for 64 bit applications. As of 10.6 most Apple applications, including the Finder, run in 64 bit when available.
There are third party applications that restore contextual menu items on 10.6 if you must have them.

Resources