So I put together a simple script to give me a right-click pop-up menu.
It works fine using blender default keys, but when I select “Maya” default keys (I know, I’m terrible) it seems to overwrite the key binding I use in the add-on.
Normally, the Maya defaults use right click for the 3D cursor. I set the 3D cursor to middle mouse click so the right click is unbound. But it still doesn’t work unless I uncheck and recheck the add-on each time I start blender. Any ideas around this?
bl_info = {
"name": "My Tools",
"description": "Customized right-click tools menu.",
"author": "Me",
"version": (0,0),
"blender": (2, 62, 0),
"location": "View3D > MyTools",
"warning": "",
"wiki_url": "",
"tracker_url": "",
"category": "3D View"}
#!/usr/bin/python
import bpy
class VIEW3D_MyTools(bpy.types.Menu):
bl_label = "My Tools"
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
view3DContext =
if bpy.context.mode == 'OBJECT':
layout.operator("object.mode_set",text="Edit Mode").mode='EDIT'
elif bpy.context.mode == 'EDIT_MESH':
layout.operator("object.mode_set",text="Object Mode").mode='OBJECT'
def register():
bpy.utils.register_module(__name__)
keyMap = bpy.context.window_manager.keyconfigs.active.keymaps['3D View']
keyMapItem = keyMap.keymap_items.new('wm.call_menu', 'RIGHTMOUSE', 'PRESS')
keyMapItem.properties.name = "VIEW3D_MyTools"
def unregister():
bpy.utils.unregister_module(__name__)
keyMapItems = bpy.context.window_manager.keyconfigs.active.keymaps['3D View'].keymap_items
for keyMapItem in keyMapItems:
if keyMapItem.idname == 'wm.call_menu' and keyMapItem.properties.name == "VIEW3D_MyTools":
keyMapItems.remove(keyMapItem)
break
if __name__ == "__main__":
register()