My goal is to print out a message when you click on the UI to change the active modifier.
I tried different methods but failed
import bpy
def message_callback(k, *kw):
print("You changed the active modifier by clicking through the UI!")
method 1
bpy.msgbus.subscribe_rna(
key=(bpy.types.ObjectModifiers, "active"),
owner="method_1",
args=(),
notify=message_callback)
method 2
bpy.msgbus.subscribe_rna(
key=bpy.context.object.modifiers.active,
owner="method_2",
args=(),
notify=message_callback)
method 3
bpy.app.handlers.depsgraph_update_post.append(message_callback)
Finally I thought of a way
I provided a draw level solution below, but the performance was poor since the draw function will run a lot on some operations, so I'm looking for another answer.
