diff --git a/RightMouseNavigation.py b/RightMouseNavigation.py index c3dc756..d0be034 100644 --- a/RightMouseNavigation.py +++ b/RightMouseNavigation.py @@ -4,7 +4,7 @@ 'name': 'Right Mouse Navigation', 'category': 'View 3D', 'author': 'Spectral Vectors', - 'version': (0, 1, 4), + 'version': (0, 1, 5), 'blender': (2, 90, 0), 'location': '3D Viewport', "description": "Enables Right Mouse Viewport Navigation" diff --git a/__init__.py b/__init__.py index 412ab54..8f90814 100644 --- a/__init__.py +++ b/__init__.py @@ -2,7 +2,7 @@ 'name': 'Right Mouse Navigation', 'category': 'View 3D', 'author': 'Spectral Vectors', - 'version': (0, 1, 4), + 'version': (0, 1, 5), 'blender': (2, 90, 0), 'location': '3D Viewport', "description": "Enables Right Mouse Viewport Navigation" @@ -16,12 +16,13 @@ addon_keymaps = [] -def register(): - bpy.utils.register_class(RightMouseNavigationPreferences) - bpy.utils.register_class(BLUI_OT_right_mouse_navigation) +def register(): + if not bpy.app.background: + bpy.utils.register_class(RightMouseNavigationPreferences) + bpy.utils.register_class(BLUI_OT_right_mouse_navigation) - register_keymaps() + register_keymaps() def register_keymaps(): keyconfig = bpy.context.window_manager.keyconfigs @@ -33,7 +34,7 @@ def register_keymaps(): else: wm = bpy.context.window_manager - kc = wm.keyconfigs.addon + kc = wm.keyconfigs.user km = kc.keymaps.new( name="3D View", @@ -94,56 +95,56 @@ def register_keymaps(): def unregister(): - - bpy.utils.unregister_class(BLUI_OT_right_mouse_navigation) - bpy.utils.unregister_class(RightMouseNavigationPreferences) - - wm = bpy.context.window_manager - kc = wm.keyconfigs.addon - - for km, kmi in addon_keymaps: - km.keymap_items.remove(kmi) - wm.keyconfigs.addon.keymaps.remove(km) - addon_keymaps.clear() - - menumodes = ["Object Mode", "Mesh", "Curve", "Armature", "Metaball", "Lattice", "Font", "Pose"] - panelmodes = ["Vertex Paint", "Weight Paint", "Image Paint", "Sculpt"] - - # Reactivating menus - # "Object Mode", "Mesh", "Curve", "Armature", "Metaball", "Lattice", - # "Font", "Pose" - for i in menumodes: - for key in wm.keyconfigs.user.keymaps[i].keymap_items: - if ( - key.idname == "wm.call_menu" - and key.type == "RIGHTMOUSE" - ): - key.active = True + if not bpy.app.background: + bpy.utils.unregister_class(BLUI_OT_right_mouse_navigation) + bpy.utils.unregister_class(RightMouseNavigationPreferences) - # Reactivating panels - # "Vertex Paint", "Weight Paint", "Image Paint", "Sculpt" - for i in panelmodes: - for key in wm.keyconfigs.user.keymaps[i].keymap_items: - if ( - key.idname == "wm.call_panel" - and key.type == "RIGHTMOUSE" - ): - key.active = True - - # Changing the Walk Modal Map back - for key in wm.keyconfigs.user.keymaps["View3D Walk Modal"].keymap_items: - if ( - key.propvalue == "CANCEL" - and key.type == "RIGHTMOUSE" - ): - key.active = True - for key in wm.keyconfigs.user.keymaps["View3D Walk Modal"].keymap_items: - if ( - key.propvalue == "CONFIRM" - and key.type == "RIGHTMOUSE" - ): - key.type = "LEFTMOUSE" - key.value = "PRESS" + wm = bpy.context.window_manager + kc = wm.keyconfigs.user + + for km, kmi in addon_keymaps: + km.keymap_items.remove(kmi) + wm.keyconfigs.user.keymaps.remove(km) + addon_keymaps.clear() + + menumodes = ["Object Mode", "Mesh", "Curve", "Armature", "Metaball", "Lattice", "Font", "Pose"] + panelmodes = ["Vertex Paint", "Weight Paint", "Image Paint", "Sculpt"] + + # Reactivating menus + # "Object Mode", "Mesh", "Curve", "Armature", "Metaball", "Lattice", + # "Font", "Pose" + for i in menumodes: + for key in wm.keyconfigs.user.keymaps[i].keymap_items: + if ( + key.idname == "wm.call_menu" + and key.type == "RIGHTMOUSE" + ): + key.active = True + + # Reactivating panels + # "Vertex Paint", "Weight Paint", "Image Paint", "Sculpt" + for i in panelmodes: + for key in wm.keyconfigs.user.keymaps[i].keymap_items: + if ( + key.idname == "wm.call_panel" + and key.type == "RIGHTMOUSE" + ): + key.active = True + + # Changing the Walk Modal Map back + for key in wm.keyconfigs.user.keymaps["View3D Walk Modal"].keymap_items: + if ( + key.propvalue == "CANCEL" + and key.type == "RIGHTMOUSE" + ): + key.active = True + for key in wm.keyconfigs.user.keymaps["View3D Walk Modal"].keymap_items: + if ( + key.propvalue == "CONFIRM" + and key.type == "RIGHTMOUSE" + ): + key.type = "LEFTMOUSE" + key.value = "PRESS" if __name__ == "__package__": register() \ No newline at end of file