UI: Only draw node menu search if categories exist
Currently, the search operator in the node add menu NODE_MT_add is drawn even if no node categories exists. This patch only draws the operator if at least one node category passes the poll. This patch is needed because some add-ons use custom search operator and do not register node categories. In this case, it is undesirable to have a search operator drawn that do nothing and is not used. One such add-on is Animation Nodes. Reviewed By: Jacques Lucke Differential Revision: https://developer.blender.org/D8576
This commit is contained in:
@@ -216,13 +216,15 @@ class NODE_MT_add(bpy.types.Menu):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator_context = 'INVOKE_DEFAULT'
|
||||
props = layout.operator("node.add_search", text="Search...", icon='VIEWZOOM')
|
||||
props.use_transform = True
|
||||
|
||||
layout.separator()
|
||||
if nodeitems_utils.has_node_categories(context):
|
||||
props = layout.operator("node.add_search", text="Search...", icon='VIEWZOOM')
|
||||
props.use_transform = True
|
||||
|
||||
# actual node submenus are defined by draw functions from node categories
|
||||
nodeitems_utils.draw_node_categories_menu(self, context)
|
||||
layout.separator()
|
||||
|
||||
# actual node submenus are defined by draw functions from node categories
|
||||
nodeitems_utils.draw_node_categories_menu(self, context)
|
||||
|
||||
|
||||
class NODE_MT_view(Menu):
|
||||
|
Reference in New Issue
Block a user