Tool System: per space/mode tool support
[blender.git] / release / scripts / startup / bl_operators / wm.py
index a9d766b29e28e8aedf66909167972e0c9c10751c..970eff34026806beb686d510ec5ad6873dfa192c 100644 (file)
@@ -2335,10 +2335,21 @@ class WM_OT_tool_set_by_name(Operator):
             name="Text",
             description="Display name of the tool",
             )
+    space_type = EnumProperty(
+            name="Type",
+            items=tuple(
+                (e.identifier, e.name, "", e. value)
+                for e in bpy.types.Space.bl_rna.properties["type"].enum_items
+            ),
+            default='EMPTY',
+            )
 
     def execute(self, context):
         from bl_ui.space_toolsystem_common import activate_by_name
-        if activate_by_name(context, context.space_data.type, self.name):
+        space_type = self.space_type
+        if space_type == 'EMPTY':
+            space_type = context.space_data.type
+        if activate_by_name(context, space_type, self.name):
             return {'FINISHED'}
         else:
             self.report({'WARNING'}, f"Tool {self.name!r} not found.")