When I execute an operator that changes mouse pointer with cursor_set("WAIT")
from Toolshelf and keep the mouse pointer over the Toolshelf, the mouse pointer stays as WAIT
after the modal operation has finished. When the mouse is then moved over to the viewport region, it reverts to default.
If the mouse is moved over to the viewport region during the operation, the mouse pointer will revert as soon the operation finishes.
If I add bpy.context.window.cursor_set('DEFAULT')
before returning, the mouse pointer will immediately revert to default, of course.
Is there a way to revert the mouse pointer to default over the Toolshelf after the modal operator finishes?
(It is not just modal operators, same thing applies to Blender's "internal" operations that sometimes take long time and "run in background", like setting a modifier's show_viewport
option to True
.)
Example code:
import bpy
from bpy.types import Operator, Panel
class MyOperator(Operator):
"""This is my operator"""
bl_idname = "my.operator"
bl_label = "My Operator"
def execute(self, context):
context.window.cursor_set("WAIT")
bpy.ops.transform.translate('INVOKE_DEFAULT')
return {'FINISHED'}
class MyTestPanel(Panel):
bl_idname = "mytestpanel"
bl_category = "My Stuff"
bl_label = "My Test Panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_context = "objectmode"
def draw(self, context):
layout = self.layout
col = layout.column(align=True)
col.label(text="My operator:")
col.operator("my.operator", text="Run my operator")
def register():
bpy.utils.register_module(__name__)
def unregister():
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()