Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a context-sensitive menu item (using "right clicking") to a file in the mac OS X finder?

I need to add a context-sensitive menu to file icons in the finder. So basically if I right click, say, the "filename.txt" icon, a submenu should pop up with "Open", "Get Info", etc but there should be an additional item that says, say, "My Program". And if user selects the "My Program" menu selection, the system will execute: "my_program.rb filename.txt".

I have Mac OS 10.6 32-bit.

I checked stack overflow and I there are posted solutions, but am a bit confused by them. Firstly, according to this stack overflow article, you have to "add a Service that enables the share facility", but this is confusing to me. What is a "service"? Is that a program with special hooks to the OS or something?

There is also an apple article for "providing a service" but again, I am a bit confused by it. Can a ruby script count as a "service"? Or do I have to do some weird Cocoa thing in objective C to access the submenu and then refer to the script in there?

Is there a simpler way to do this? Maybe an open source program that I haven't yet encountered?

like image 409
Steve Quezadas Avatar asked May 26 '12 21:05

Steve Quezadas


People also ask

How do you create a new file from the right click context menu Mac?

Install New File Menu and enable it as a Finder extension. To do so, open the Settings app, go to Extensions and enable it. What is this? Right-click inside a Finder window and you will see options to create a new text file, a new RTF document, a new Pages document, etc.

How do you use the context menu on a Mac?

Control-click on a Mac is similar to right-click on a Windows computer—it's how you open shortcut (or contextual) menus on a Mac. Control-click: Press and hold the Control key while you click an item. For example, Control-click an icon, a window, the toolbar, the desktop, or another item.

How do you customize the context menu on a Mac?

The context menu appears when you Control+click, right+click, or two-finger click something on a Mac. Most of the items in a context menu appear depending on what was clicked and which app you are using.


1 Answers

You should use services.Take a look at Services Implementation Guide and MakingServices.

Services are features exported by your application for the benefit of other applications. Services let you share the resources and capabilities of your application with other applications in the system.

Services are are accessible from contextual menu.

like image 130
Parag Bafna Avatar answered Sep 22 '22 16:09

Parag Bafna