Skip to main content
Tweeted twitter.com/StackBlender/status/659795804924809216
'blender-2.70' tag is not official - removed, added scripting tags
Link
Ray Mairlot
  • 29.4k
  • 12
  • 105
  • 126
Source Link
Trirop
  • 388
  • 2
  • 14

How to register keymaps for all editor types?

I want to write an addon, which enables you to switch quickly, via a pie menu, between the editor types. (e.g. Node Editor, 3D View, Graph Editor, etc...) To get my shortcut working, I need to register the same keymap for every space or editor type.

(e.g.:keymap_items.new("wm.call_menu_pie", type = "E",alt=True, value = "PRESS"))

Right now I got it working with only one editor type:

keyconfigs.addon.keymaps.new(name = "Node Editor", space_type = "NODE_EDITOR")

I know, I could simply register my keymap for every single editor type with a loop, but I am sure there is a more convenient and beatiful way to accomplish my objective.

( Maybe something like space_type = "WINDOW"?)

PS: My current registration code looks like this:

addon_keymaps = []
def register_keymaps():
    global addon_keymaps
    wm = bpy.context.window_manager
    km = wm.keyconfigs.addon.keymaps.new(name = "Node Editor", space_type = "NODE_EDITOR")
    kmi = km.keymap_items.new("wm.call_menu_pie", type = "E",alt=True, value = "PRESS")
    kmi.properties.name = "view3d.switcher"
    addon_keymaps.append(km)