Reputation: 19737
I am implementing a contextual service for mac OS. When you select a text in an application that support services, a new subitem is added to a services menu. I followed Services Implementation Guide.
Now this works as intended. Now how do I move the item from Services menu to be directly in the contextual menu (so that the user does not have to navigate through Services and can directly use my service)? Is that even possible?
EDIT: After some more research I am still not any better. E.g., this SO answer claims that it is not possible to add a contextual menu item directly in the menu, only through services. On the other hand, this SO answer claims that it is possible and provides some links on further resources - however, the sample code that is linked in it is not on the Apple site anymore, and the tutorial linked seems to be outdated as well (all its resources are pointing to non-existent pages).
Upvotes: 9
Views: 4635
Reputation: 31
Run the following command in the terminal:
defaults write -g NSServicesMinimumItemCountForContextSubmenu -int 999
Then restart the application where you want to use the contextual menu. Credit: https://www.maketecheasier.com/edit-context-menu-macos/
I wish there was a way to put selected (frequently used) Services into the main contextual menu, but so far the only solution seems to be all or nothing.
You can change 999 to a smaller number if you want. That will change the threshold. The system default I guess is 4 or 5.
Upvotes: 2
Reputation:
It has nothing to do with your service in particular. Services are displayed directly in the Finder context menu if there are four or fewer relevant services available, and in a submenu if there are five or more:
Note the extended “Services” submenu has also been merged to become part of the general right-click menu because it dropped under 5 items. That’s because the “Services” section becomes it’s own dedicated submenu once more than four items or Service options are available for a given file, filetype, or folder, but with under five items, the Services menu blends into the general right-click menu of OS X.
-- http://osxdaily.com/2013/05/14/remove-services-contextual-menu-mac-os-x/
Upvotes: 5