I’m trying to write an add-on that appears in the Header of several spaces. I’m trying to update the UI based on the current space that is active. Using this post as an example,
https://blender.stackexchange.com/questions/135968/how-can-i-catch-a-workspace-change-event, I came up with the following code:
def notify_test(context):
print(context.area)
handle = object()
subscribe_to = bpy.types.Context, "area"
bpy.msgbus.subscribe_rna(
key=subscribe_to,
owner=handle,
args=(bpy.context,),
notify=notify_test,
)
bpy.msgbus.publish_rna(key=subscribe_to)
context.area is None and the message event doesn’t trigger when the Context’s area is changed.
I’ve also tried:
subscribe_to = bpy.types.Space, "type"
Can anyone please help me to detect when a Space has been changed?
Thank you!