@@ -67,12 +67,33 @@ def update_node_keymap(self, context):
6767 key .active = addon_prefs .enable_for_node_editors
6868
6969
70- def update_rebind_3dview_keymap (self , context ):
71- self .rebind_3dview_keymap (context , self .rmb_pan_rotate )
70+ def update_rebind_3dview_keymap (self , context ):
71+ wm = context .window_manager
72+ active_keyconfig = wm .keyconfigs .active
73+ blender_keyconfig = wm .keyconfigs ["Blender" ]
74+ user_keyconfig = wm .keyconfigs ["Blender user" ]
7275
76+ try :
77+ self .rebind_3dview_keymap (active_keyconfig , self .rmb_pan_rotate )
78+ except KeyError :
79+ self .rebind_3dview_keymap (blender_keyconfig , self .rmb_pan_rotate )
80+ except KeyError :
81+ self .rebind_3dview_keymap (user_keyconfig , self .rmb_pan_rotate )
7382
74- def update_rebind_switch_nav_rotate (self , context ):
75- self .rebind_switch_nav_rotate (context , self .rmb_rotate_switch )
83+
84+ def update_rebind_switch_nav_rotate (self , context ):
85+ wm = context .window_manager
86+ active_keyconfig = wm .keyconfigs .active
87+ addon_keyconfig = wm .keyconfigs .addon
88+ blender_keyconfig = wm .keyconfigs ["Blender" ]
89+ user_keyconfig = wm .keyconfigs ["Blender user" ]
90+
91+ try :
92+ self .rebind_switch_nav_rotate (active_keyconfig , addon_keyconfig , self .rmb_rotate_switch )
93+ except KeyError :
94+ self .rebind_switch_nav_rotate (blender_keyconfig , addon_keyconfig , self .rmb_rotate_switch )
95+ except KeyError :
96+ self .rebind_switch_nav_rotate (user_keyconfig , addon_keyconfig , self .rmb_rotate_switch )
7697
7798
7899class RightMouseNavigationPreferences (AddonPreferences ):
@@ -152,13 +173,9 @@ class RightMouseNavigationPreferences(AddonPreferences):
152173 update = update_rebind_switch_nav_rotate ,
153174 )
154175
155- def rebind_3dview_keymap (self , context , isActive ):
156- wm = context .window_manager
157- active_kc = wm .keyconfigs .active
158- addon_kc = wm .keyconfigs .addon
159-
176+ def rebind_3dview_keymap (self , keyconfig , isActive ):
160177 if isActive :
161- for key in active_kc .keymaps ["3D View" ].keymap_items :
178+ for key in keyconfig .keymaps ["3D View" ].keymap_items :
162179 if key .idname == "view3d.cursor3d" and key .type == "RIGHTMOUSE" :
163180 key .type = "MIDDLEMOUSE"
164181 key .value = "CLICK"
@@ -201,7 +218,7 @@ def rebind_3dview_keymap(self, context, isActive):
201218 if key .idname == "transform.translate" and key .type == "RIGHTMOUSE" :
202219 key .type = "MIDDLEMOUSE"
203220 else :
204- for key in active_kc .keymaps ["3D View" ].keymap_items :
221+ for key in keyconfig .keymaps ["3D View" ].keymap_items :
205222 if key .idname == "view3d.cursor3d" and key .type == "MIDDLEMOUSE" :
206223 key .type = "RIGHTMOUSE"
207224 key .value = "CLICK"
@@ -244,52 +261,48 @@ def rebind_3dview_keymap(self, context, isActive):
244261 if key .idname == "transform.translate" and key .type == "MIDDLEMOUSE" :
245262 key .type = "RIGHTMOUSE"
246263
247- def rebind_switch_nav_rotate (self , context , isActive ):
248- wm = context .window_manager
249- active_kc = wm .keyconfigs .active
250- addon_kc = wm .keyconfigs .addon
251-
264+ def rebind_switch_nav_rotate (self , keyconfig , addon_kc , isActive ):
252265 if isActive :
253266 for key in addon_kc .keymaps ["3D View" ].keymap_items :
254267 if key .idname == "rmn.right_mouse_navigation" :
255268 key .type = "RIGHTMOUSE"
256269 key .value = "PRESS"
257270 key .alt = True
258- for key in active_kc .keymaps ["3D View" ].keymap_items :
271+ for key in keyconfig .keymaps ["3D View" ].keymap_items :
259272 if key .idname == "view3d.rotate" and key .type == "RIGHTMOUSE" :
260273 key .type = "RIGHTMOUSE"
261274 key .value = "CLICK_DRAG"
262275 key .alt = False
263- for i in menumodes :
264- for key in active_kc .keymaps [i ].keymap_items :
276+ for i in self . menumodes :
277+ for key in keyconfig .keymaps [i ].keymap_items :
265278 if key .idname == "wm.call_menu" and key .type == "RIGHTMOUSE" :
266279 key .active = True
267280 key .value = "CLICK"
268- for i in panelmodes :
269- for key in active_kc .keymaps [i ].keymap_items :
270- if key .idname == "wm.call_panel" and key .type == "RIGHTMOUSE" and key . active :
271- key .active = False
281+ for i in self . panelmodes :
282+ for key in keyconfig .keymaps [i ].keymap_items :
283+ if key .idname == "wm.call_panel" and key .type == "RIGHTMOUSE" :
284+ key .active = True
272285 key .value = "CLICK"
273286 else :
274287 for key in addon_kc .keymaps ["3D View" ].keymap_items :
275288 if key .idname == "rmn.right_mouse_navigation" :
276289 key .type = "RIGHTMOUSE"
277290 key .value = "PRESS"
278291 key .alt = False
279- for key in active_kc .keymaps ["3D View" ].keymap_items :
292+ for key in keyconfig .keymaps ["3D View" ].keymap_items :
280293 if key .idname == "view3d.rotate" and key .type == "RIGHTMOUSE" :
281294 key .type = "RIGHTMOUSE"
282295 key .value = "CLICK_DRAG"
283296 key .alt = True
284- for i in menumodes :
285- for key in active_kc .keymaps [i ].keymap_items :
297+ for i in self . menumodes :
298+ for key in keyconfig .keymaps [i ].keymap_items :
286299 if key .idname == "wm.call_menu" and key .type == "RIGHTMOUSE" :
287300 key .active = False
288301 key .value = "PRESS"
289- for i in panelmodes :
290- for key in active_kc .keymaps [i ].keymap_items :
302+ for i in self . panelmodes :
303+ for key in keyconfig .keymaps [i ].keymap_items :
291304 if key .idname == "wm.call_panel" and key .type == "RIGHTMOUSE" :
292- key .active = True
305+ key .active = False
293306 key .value = "PRESS"
294307
295308 def draw (self , context ):
0 commit comments