Fix menu search omitting the outliner context menu
Use a regular context menu as a fallback for the outliner. If there are no specific actions for the item under the cursor, fall through to opening a regular menu. This lets menu search find the context menu items which were previously unavailable as menu search wont run operators.
This commit is contained in:
@@ -104,20 +104,26 @@ class OUTLINER_MT_editor_menus(Menu):
|
||||
layout.menu("OUTLINER_MT_edit_datablocks")
|
||||
|
||||
|
||||
class OUTLINER_MT_context(Menu):
|
||||
bl_label = "Outliner"
|
||||
class OUTLINER_MT_context_menu(Menu):
|
||||
bl_label = "Outliner Context Menu"
|
||||
|
||||
def draw(self, context):
|
||||
space = context.space_data
|
||||
|
||||
def draw(self, _context):
|
||||
layout = self.layout
|
||||
|
||||
layout.menu("OUTLINER_MT_context_view")
|
||||
if space.display_mode == 'VIEW_LAYER':
|
||||
OUTLINER_MT_collection_new.draw_without_context_menu(context, layout)
|
||||
layout.separator()
|
||||
|
||||
layout.menu("OUTLINER_MT_context_menu_view")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.menu("INFO_MT_area")
|
||||
|
||||
|
||||
class OUTLINER_MT_context_view(Menu):
|
||||
class OUTLINER_MT_context_menu_view(Menu):
|
||||
bl_label = "View"
|
||||
|
||||
def draw(self, _context):
|
||||
@@ -236,25 +242,25 @@ class OUTLINER_MT_collection(Menu):
|
||||
|
||||
layout.separator()
|
||||
|
||||
OUTLINER_MT_context.draw(self, context)
|
||||
OUTLINER_MT_context_menu.draw(self, context)
|
||||
|
||||
|
||||
class OUTLINER_MT_collection_new(Menu):
|
||||
bl_label = "Collection"
|
||||
|
||||
def draw(self, context):
|
||||
# Note: this menu is used in any context where collections exist,
|
||||
# as a generic way to add data. The names here are expanded because
|
||||
# this menu is often expended without it's title.
|
||||
|
||||
layout = self.layout
|
||||
|
||||
@staticmethod
|
||||
def draw_without_context_menu(context, layout):
|
||||
layout.operator("outliner.collection_new", text="New Collection").nested = False
|
||||
layout.operator("outliner.id_paste", text="Paste Data-Blocks", icon='PASTEDOWN')
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
self.draw_without_context_menu(context, layout)
|
||||
|
||||
layout.separator()
|
||||
|
||||
OUTLINER_MT_context.draw(self, context)
|
||||
OUTLINER_MT_context_menu.draw(self, context)
|
||||
|
||||
|
||||
class OUTLINER_MT_object(Menu):
|
||||
@@ -303,7 +309,7 @@ class OUTLINER_MT_object(Menu):
|
||||
|
||||
layout.separator()
|
||||
|
||||
OUTLINER_MT_context.draw(self, context)
|
||||
OUTLINER_MT_context_menu.draw(self, context)
|
||||
|
||||
|
||||
class OUTLINER_PT_filter(Panel):
|
||||
@@ -423,8 +429,8 @@ classes = (
|
||||
OUTLINER_MT_collection_visibility,
|
||||
OUTLINER_MT_collection_view_layer,
|
||||
OUTLINER_MT_object,
|
||||
OUTLINER_MT_context,
|
||||
OUTLINER_MT_context_view,
|
||||
OUTLINER_MT_context_menu,
|
||||
OUTLINER_MT_context_menu_view,
|
||||
OUTLINER_PT_filter,
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user