I want to write a
Handler that runs code only when the user stops translating an object, using
bpy.ops.transform.translate (the 'G' key). So while the user is sliding the mouse around, nothing should happen besides the object being translated. But when they exit the modal
operator (by left-clicking or pressing 'enter'), my code should run.
@bpy.app.handlers.persistent def detect_change(scene): op = bpy.context.active_operator opname = op.bl_idname.replace("_OT_", ".").lower() if op else '' # On entering translate mode, start checking for exit if opname == "transform.translate": waiting = True # This will be some sort of persistent variable. return # If not in translate mode, then run code elif waiting: my_function() waiting = False # Add the handler bpy.app.handlers.scene_update_post.append(detect_change)
The only problem is that after exiting the translate modal operator, the active_operator remains at
transform.translate. It doesn't switch until another operator is called.
Any way to either force the operator to update to
None or to detect exiting the modal operator?