[Bf-blender-cvs] [c4c2c27f971] blender2.8: Fix context menu w/o an active object

Campbell Barton noreply at git.blender.org
Thu Dec 20 05:32:15 CET 2018


Commit: c4c2c27f971631eb130b1964c33f83e748411c5a
Author: Campbell Barton
Date:   Thu Dec 20 15:26:27 2018 +1100
Branches: blender2.8
https://developer.blender.org/rBc4c2c27f971631eb130b1964c33f83e748411c5a

Fix context menu w/o an active object

Also remove special case when no items are selected,
since this only has one or two menu items, one being the add menu
which can be better accessed from the header or add shortcut.

If the no-selection case is to have it's own alternate menu - it should
be more complete before enabling.

===================================================================

M	release/scripts/startup/bl_ui/space_node.py
M	release/scripts/startup/bl_ui/space_view3d.py

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py
index 73afb62567c..9754cf64a86 100644
--- a/release/scripts/startup/bl_ui/space_node.py
+++ b/release/scripts/startup/bl_ui/space_node.py
@@ -328,12 +328,15 @@ class NODE_MT_specials(Menu):
         layout = self.layout
 
         # If nothing is selected
+        # (disabled for now until it can be made more useful).
+        '''
         selected_nodes_len = len(context.selected_nodes)
         if selected_nodes_len == 0:
             layout.operator_context = 'INVOKE_DEFAULT'
             layout.menu("NODE_MT_add")
             layout.operator("node.clipboard_paste", text="Paste")
             return
+        '''
 
         # If something is selected
         layout.operator_context = 'INVOKE_DEFAULT'
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 3507ddb6c1f..85c43e78e0a 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -1733,17 +1733,23 @@ class VIEW3D_MT_object_specials(Menu):
         obj = context.object
         is_eevee = context.scene.render.engine == 'BLENDER_EEVEE'
 
-        # If nothing is selected
         selected_objects_len = len(context.selected_objects)
+
+        # If nothing is selected
+        # (disabled for now until it can be made more useful).
+        '''
         if selected_objects_len == 0:
 
             layout.menu("VIEW3D_MT_add", text="Add")
             layout.operator("view3d.pastebuffer", text="Paste Objects", icon='PASTEDOWN')
 
             return
+        '''
 
         # If something is selected
-        if obj.type == 'MESH':
+        if obj is None:
+            pass
+        elif obj.type == 'MESH':
 
             layout.operator("object.shade_smooth", text="Shade Smooth")
             layout.operator("object.shade_flat", text="Shade Flat")
@@ -1758,7 +1764,7 @@ class VIEW3D_MT_object_specials(Menu):
             if selected_objects_len > 1:
                 layout.operator("object.join")
 
-        if obj.type == 'CAMERA':
+        elif obj.type == 'CAMERA':
             layout.operator_context = 'INVOKE_REGION_WIN'
 
             if obj.data.type == 'PERSP':
@@ -1788,7 +1794,7 @@ class VIEW3D_MT_object_specials(Menu):
                     props.input_scale = 0.02
                     props.header_text = "DOF Distance: %.3f"
 
-        if obj.type in {'CURVE', 'FONT'}:
+        elif obj.type in {'CURVE', 'FONT'}:
             layout.operator_context = 'INVOKE_REGION_WIN'
 
             props = layout.operator("wm.context_modal_mouse", text="Extrude Size")
@@ -1807,14 +1813,14 @@ class VIEW3D_MT_object_specials(Menu):
 
             layout.operator_menu_enum("object.origin_set", text="Set Origin...", property="type")
 
-        if obj.type == 'GPENCIL':
+        elif obj.type == 'GPENCIL':
             layout.operator("gpencil.convert", text="Convert to Path").type = 'PATH'
             layout.operator("gpencil.convert", text="Convert to Bezier Curves").type = 'CURVE'
             layout.operator("gpencil.convert", text="Convert to Mesh").type = 'POLY'
 
             layout.operator_menu_enum("object.origin_set", text="Set Origin...", property="type")
 
-        if obj.type == 'EMPTY':
+        elif obj.type == 'EMPTY':
             layout.operator_context = 'INVOKE_REGION_WIN'
 
             props = layout.operator("wm.context_modal_mouse", text="Empty Draw Size")
@@ -1823,7 +1829,7 @@ class VIEW3D_MT_object_specials(Menu):
             props.input_scale = 0.01
             props.header_text = "Empty Draw Size: %.3f"
 
-        if obj.type == 'LIGHT':
+        elif obj.type == 'LIGHT':
             light = obj.data
 
             layout.operator_context = 'INVOKE_REGION_WIN'
@@ -2826,11 +2832,15 @@ class VIEW3D_MT_edit_mesh_specials(Menu):
 
         layout.operator_context = 'INVOKE_REGION_WIN'
 
+        # If nothing is selected
+        # (disabled for now until it can be made more useful).
+        '''
         # If nothing is selected
         if not (selected_verts_len or selected_edges_len or selected_faces_len):
             layout.menu("VIEW3D_MT_mesh_add", text="Add")
 
             return
+        '''
 
         # Else something is selected



More information about the Bf-blender-cvs mailing list