Page MenuHome

Addon's keymaps are not registered at Blender opening if the addon's enable state is saved in user preferences
Closed, DuplicatePublic

Description

Blender Version
Broken: 2.80

Short description of error

The code bellow illustrates the issue, it register a new shortcut (here for example the translate operator on numpad asterix key). When the addon is activated for the first time, then the shortcut works correctly. If this activation state is saved in user preferences and then Blender reopenned, the shortcut does not works anymore.

bl_info = {
	'name': 'Test',
	'blender': (2, 80, 0),
	'category': '3D View'
	}

import bpy

def register():
	wm = bpy.context.window_manager
	kc =  wm.keyconfigs.active
	km = kc.keymaps['3D View']
	kmi = km.keymap_items.new(idname='transform.translate', type='NUMPAD_ASTERIX', value='PRESS')


def unregister():
	wm = bpy.context.window_manager
	km = wm.keyconfigs.active.keymaps['3D View']
	kmi = km.keymap_items.remove(km.keymap_items['transform.translate'])

if __name__ == "__main__":
	register()

Details

Type
Bug