How can I add my operator to existing right-click (context menu) in the shader editor? enter image description here

  • $\begingroup$ It is not generic right-click menu, in the 2.79 it is called "specials" menu. Now in 2.8 it moved to right-click instead of "w" button. $\endgroup$
    – Helmy
    Commented Aug 28, 2019 at 17:03

3 Answers 3


The Shader Editor context menu is called NODE_MT_context_menu (found by inspecting Preferences> Keymap> Node Editor and looking for Right Mouse) and we can 'append' (add) a draw function, which draws your menu item, into the existing menu. In the example below I have used the Node Editor's existing 'Duplicate' operator.

def draw_menu(self, context):
    layout = self.layout
    layout.operator("node.duplicate_move", text="My new context menu item")

def register():

def unregister():


  • The draw_menu function deals with the UI that you want to add to the context menu (an operator) by using the bl_idname of your operator - in this case node.duplicate_move.
  • The register function should contain, in addition to the code that registers your operator, the code to append that UI into the existing menu.
  • In the case of an add-on, the unregister function will remove the UI you added.


  • The separator() line is not required, but useful for keeping your UI separate from the existing one.
  • prepend can be used instead of append to add items to the top of the menu instead of the bottom.

Some more information about menus can be found in the 2.80 Python API documentation. A few examples of extending the existing UI can be found in the Python templates included with Blender via the Templates menu in the Text Editor header.


Ray's excellent answer and explanation still hold true for Blender 3.x and current the API. These also helped me with adding menu items:

  • Searching Keymap for "context menu" gives what's available across for all editors. enter image description here
  • Enabling Developer Extras and Python Tooltips in Preferences ... Interface ... Display gives info on hover in context of the editor / workspace you're in currently. enter image description here

For anyone who came here looking for the context menu for mesh editing mode, the keyword is VIEW3D_MT_edit_mesh_context_menu

so the code would be

def register():

Which is the menu that appears when you right-click (by default) in Edit Mode. For some reason, I couldn't find it in the Blender API reference.




You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .