Outliner: Hide library overrdies context menu when no IDs are selected

The library overrides context menu operators only make sense when at
least one ID is selected in the Outliner. So don't show them unless
that's the case. This also means the menu items don't show up anymore
for things like RNA properties, or the overridden properties in the
Library Overrides Properties view.

Also see 7eda9d8dda and the previous commit.
This commit is contained in:
Julian Eisel 2022-09-09 13:52:51 +02:00
parent 860c3dce1b
commit e254d8867d
1 changed files with 13 additions and 6 deletions

View File

@ -323,17 +323,20 @@ class OUTLINER_MT_object(Menu):
OUTLINER_MT_context_menu.draw_common_operators(layout)
def has_selected_ids_in_context(context):
if hasattr(context, "id"):
return True
if len(context.selected_ids) > 0:
return True
return False
class OUTLINER_MT_asset(Menu):
bl_label = "Assets"
@classmethod
def poll(cls, context):
if hasattr(context, "id"):
return True
if len(context.selected_ids) > 0:
return True
return False
return has_selected_ids_in_context(context)
def draw(self, _context):
layout = self.layout
@ -346,6 +349,10 @@ class OUTLINER_MT_asset(Menu):
class OUTLINER_MT_liboverride(Menu):
bl_label = "Library Override"
@classmethod
def poll(cls, context):
return has_selected_ids_in_context(context)
def draw(self, _context):
layout = self.layout