Tutorial How to add to the Project modules context menu

Delisa Mason edited this page Aug 29, 2011 · 1 revision

What is the context menu?

When you have a project open, there is a tree view of the files in your project to the left of your editing window. If you right click on a file or folder in this view, this is the context menu.

So, how do I customize this menu?

Your plugin object should define the method project_context_menus which should return a Redcar::Menu object. This will be merged into the project context menu.

Here is an example of an item that displays a Hello World message box when selected. It bears mentioning that the default priority of a menu item is 50, but here we explicitly set it so there’s no confusion.

module Redcar
  class MyPlugin
    def self.project_context_menus(tree, node, controller)
      Redcar::Menu::Builder.build do
        group(:priority => 50) {
          item("Say hello") { Application::Dialog.message_box("Hello World!") }
        }
      end
    end
  end
end