Stopped deleting keymaps
This commit is contained in:
parent
caefc27d54
commit
ceae38219f
1 changed files with 31 additions and 11 deletions
|
@ -407,10 +407,14 @@ def ChangeValuesOfSelection(ValueToChange,ValueToSet):
|
||||||
|
|
||||||
|
|
||||||
class UpdateUI(bpy.types.Operator): #This function will put the values of the selected face into the UI elements
|
class UpdateUI(bpy.types.Operator): #This function will put the values of the selected face into the UI elements
|
||||||
bl_idname = "ui.update"
|
"""Tooltip"""
|
||||||
|
bl_idname = "update.ui"
|
||||||
bl_label = "Updates the UI with values from selection"
|
bl_label = "Updates the UI with values from selection"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return context.object is not None and context.selected_objects
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
if(bpy.context.object.mode == 'EDIT'):
|
if(bpy.context.object.mode == 'EDIT'):
|
||||||
obj = bpy.context.scene.objects.active
|
obj = bpy.context.scene.objects.active
|
||||||
|
@ -441,15 +445,34 @@ class UpdateUI(bpy.types.Operator): #This function will put the values of the se
|
||||||
|
|
||||||
classes = (ExportCOL,ImportCOL, CollisionPanel,InitialValues,CollisionProperties,UpdateUI) #list of classes to register/unregister
|
classes = (ExportCOL,ImportCOL, CollisionPanel,InitialValues,CollisionProperties,UpdateUI) #list of classes to register/unregister
|
||||||
addon_keymaps = []
|
addon_keymaps = []
|
||||||
|
kmi=None
|
||||||
|
|
||||||
|
|
||||||
|
def add_hotkey():
|
||||||
|
wm = bpy.context.window_manager
|
||||||
|
kc = wm.keyconfigs.user
|
||||||
|
km = kc.keymaps.new(name='3D View', space_type='VIEW_3D')
|
||||||
|
kmi = km.keymap_items.new(UpdateUI.bl_idname, 'SELECTMOUSE', 'PRESS', any=True,head=True)
|
||||||
|
kmi.active = True
|
||||||
|
addon_keymaps.append((km, kmi))
|
||||||
|
|
||||||
|
def remove_hotkey():
|
||||||
|
''' clears all addon level keymap hotkeys stored in addon_keymaps '''
|
||||||
|
wm = bpy.context.window_manager
|
||||||
|
kc = wm.keyconfigs.user
|
||||||
|
km = kc.keymaps['3D View']
|
||||||
|
|
||||||
|
for km, kmi in addon_keymaps:
|
||||||
|
#km.keymap_items.remove(kmi)
|
||||||
|
wm.keyconfigs.user.keymaps.remove(km)
|
||||||
|
addon_keymaps.clear()
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
for i in classes:
|
for i in classes:
|
||||||
register_class(i)
|
register_class(i)
|
||||||
Scene.ColEditor = PointerProperty(type=CollisionProperties) #store in the scene
|
Scene.ColEditor = PointerProperty(type=CollisionProperties) #store in the scene
|
||||||
#handle the keymap
|
#handle the keymap
|
||||||
wm = bpy.context.window_manager
|
add_hotkey()
|
||||||
km = wm.keyconfigs.addon.keymaps.new(name='3D View', space_type='VIEW_3D')
|
|
||||||
kmi = km.keymap_items.new("object.updateui", 'SELECTMOUSE', 'PRESS', any=True)
|
|
||||||
addon_keymaps.append(km)
|
|
||||||
|
|
||||||
bpy.types.INFO_MT_file_export.append(menu_export) #Add to export menu
|
bpy.types.INFO_MT_file_export.append(menu_export) #Add to export menu
|
||||||
bpy.types.INFO_MT_file_import.append(menu_import) #Add to export menu
|
bpy.types.INFO_MT_file_import.append(menu_import) #Add to export menu
|
||||||
|
@ -467,11 +490,8 @@ def unregister():
|
||||||
bpy.types.INFO_MT_file_export.remove(menu_export)
|
bpy.types.INFO_MT_file_export.remove(menu_export)
|
||||||
bpy.types.INFO_MT_file_import.remove(menu_import)
|
bpy.types.INFO_MT_file_import.remove(menu_import)
|
||||||
# handle the keymap
|
# handle the keymap
|
||||||
wm = bpy.context.window_manager
|
#remove_hotkey()
|
||||||
for km in addon_keymaps:
|
|
||||||
wm.keyconfigs.addon.keymaps.remove(km)
|
|
||||||
# clear the list
|
|
||||||
addon_keymaps.clear()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue