There doesn't seem to be a casecontext-sensitive "Specials" menu for the Sequencer(like shortcut key 'w' in 3d View). How do I add one to the Sequencer with python scripting?
(I know about the "Add" menu in the sequencer, and options can be added to this one, but I need a new menu only containing casecontext-sensitive editing options. Ex. if there is a gap between two strips at the mouse cursor position, then a "Remove gap" option would become selectable in the menu.)
This is where I am at the moment(menu containing the add menu options):
import bpy
from bpy.types import Menu
class SEQUENCER_MT_edit(Menu):
bl_label = "Edit"
bl_idname = "sequencer.edit_menu" # ID name of the class that code will call, lowercase
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("sequencer.movie_strip_add", text="Movie") # Example options
layout.operator("sequencer.image_strip_add", text="Image")
layout.operator("sequencer.sound_strip_add", text="Sound")
layout.menu("SEQUENCER_MT_add_effect")
addon_keymaps = []
def register():
bpy.utils.register_class(SEQUENCER_MT_edit)
# handle the keymap
wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
if kc:
km = wm.keyconfigs.addon.keymaps.new(name='Sequencer', space_type='SEQUENCE_EDITOR')
km = wm.keyconfigs.addon.keymaps.new(name='3D View', space_type='VIEW_3D')
kmi = km.keymap_items.new(SEQUENCER_MT_edit.bl_idname, type='RIGHTMOUSE', value='PRESS', shift=True)
addon_keymaps.append((km, kmi))
def unregister():
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()
bpy.utils.unregister_class(SEQUENCER_MT_edit)
if __name__ == "__main__":
register()