Skip to content
Snippets Groups Projects
Commit 52551aa2 authored by Campbell Barton's avatar Campbell Barton
Browse files

bugfix [#23787] Addon keybindings assume view3d keymaps are available.

parent 1c53e912
No related branches found
No related tags found
No related merge requests found
......@@ -793,8 +793,12 @@ def register():
bpy.types.Scene.SURFSK_precision = bpy.props.IntProperty(name="Precision", description="Precision level of the surface calculation", default=4, min=0, max=100000)
bpy.types.Scene.SURFSK_keep_strokes = bpy.props.BoolProperty(name="Keep strokes", description="Keeps the sketched strokes after adding the surface", default=False)
keymap_item_add_surf = bpy.data.window_managers[0].keyconfigs.default.keymaps["3D View"].items.new("GPENCIL_OT_SURFSK_add_surface","E","PRESS", key_modifier="D")
keymap_item_stroke_to_curve = bpy.data.window_managers[0].keyconfigs.default.keymaps["3D View"].items.new("GPENCIL_OT_SURFSK_strokes_to_curves","C","PRESS", key_modifier="D")
kc = bpy.data.window_managers[0].keyconfigs.default
km = kc.keymaps.get("3D View")
if km is None:
km = kc.keymaps.new(name="3D View")
keymap_item_add_surf = km.items.new("GPENCIL_OT_SURFSK_add_surface","E","PRESS", key_modifier="D")
keymap_item_stroke_to_curve = km.items.new("GPENCIL_OT_SURFSK_strokes_to_curves","C","PRESS", key_modifier="D")
def unregister():
......@@ -803,7 +807,8 @@ def unregister():
del bpy.types.Scene.SURFSK_precision
del bpy.types.Scene.SURFSK_keep_strokes
km = bpy.data.window_managers[0].keyconfigs.default.keymaps["3D View"]
kc = bpy.data.window_managers[0].keyconfigs.default
km = kc.keymaps["3D View"]
for kmi in km.items:
if kmi.idname == 'wm.call_menu':
if kmi.properties.name == "GPENCIL_OT_SURFSK_add_surface":
......
......@@ -725,21 +725,28 @@ def _add_tface_buttons(self, context):
def register():
''' mostly to get the keymap working '''
km = bpy.context.window_manager.keyconfigs['Blender'].\
keymaps['Object Mode']
kc = bpy.context.window_manager.keyconfigs['Blender']
km = kc.keymaps.get("Object Mode")
if km is None:
km = kc.keymaps.new(name="Object Mode")
kmi = km.items.new('wm.call_menu', 'C', 'PRESS', ctrl=True)
kmi.properties.name = 'VIEW3D_MT_copypopup'
km = bpy.context.window_manager.keyconfigs['Blender'].keymaps['Pose']
try:
kmi = km.items['pose.copy']
km = kc.keymaps.get("Pose")
if km is None:
km = kc.keymaps.new(name="Pose")
kmi = km.items.get("pose.copy")
if kmi is not None:
kmi.idname = 'wm.call_menu'
except KeyError:
else:
kmi = km.items.new('wm.call_menu', 'C', 'PRESS', ctrl=True)
kmi.properties.name = 'VIEW3D_MT_posecopypopup'
for menu in _layer_menus:
bpy.types.register(menu)
bpy.types.DATA_PT_texface.append(_add_tface_buttons)
km = bpy.context.window_manager.keyconfigs.active.keymaps['Mesh']
km = kc.keymaps.get("Mesh")
if km is None:
km = kc.keymaps.new(name="Mesh")
kmi = km.items.new('wm.call_menu', 'C', 'PRESS')
kmi.ctrl = True
kmi.properties.name = 'MESH_MT_CopyFaceSettings'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment