Okay well let me start there. I was only looking for an example where you wanted proof people in an open source project should be able to add a function call to window events and everything else possible.
I will also come back or repost when I find you another of hundreds if not thousands of examples where real access to the APIs and events makes sense to you. I bet you could think of one if you tried.
Let me go back to the depsgraph update function to monitor when sculpt mode is switching and see if leaving the window triggers that toggle and if it allow one to fix this minor example/annoyance in particular.
Okay so I would need to know what value the toggle is changing right? Like your saying you want to monitor when the value parameter defining sculpt mode is changed.
Let me see if I got this straight and again thanks for your help in setting me straight how this is going to be so much better then the window became active handler.
The link you provided shows the handlers. I have seen that nothing seemed right, and the documentation is spares to none existent there. Maybe there is somewhere that page should link to that is more helpful.
bpy.app.handlers.depsgraph_update_post
or maybe
bpy.app.handlers.depsgraph_update_pre
is better to stop the system from changing it in the first place. Still I would want to allow a user to change it but not the system (unknown where or why it disabled it, so maybe it’s deeper in the code that that has to be fixed).
Here are the first questions I guess I could answer with some testing.
How often is that general function firing. I think I just want one when the window becomes active. Are you saying I would write a function in which it would have to check to see if the window is active every time any parameter on the entire system changes?
Yup I am totally lost here what you think I would do with that?
I will just post this now and come back if anything clicks in the next few hours or days.
I have got some of the answers from this post.
active_object = bpy.context.view_layer.objects.active
if active_object.mode == "SCULPT" and not active_object.use_dynamic_topology_sculpting:
bpy.ops.sculpt.dynamic_topology_toggle()
This is more what the function would be and not where to put it.
It does help to understand what dynamic_topology_toggle is changing. active_object.use_dynamic_topology_sculpting
Unfortunately following the (3rd unpostable) link shows it is read_only (another limited thing because of some magic mystery in the toggle function. Let’s not get into operator overrides and the better idea of the toggle function allowing arguments. Nor the fact that the info window doesn’t reveal anything useful other then the toggle function.)
I am guessing you are saying we want to monitor that for changes through some other more general function?
There it was also discussed about the also undocumented msgbus?
Searching on that led me to this article
Anyway I am thinking if you monitored that parameter (read_only) you need to know what function is calling it in order to not change it unless the user toggles it from the UI.
Anyway at this point I find myself here
developer blender org D2917?id=9615
which is marked/tagged “Abandoned” but it’s the only thing I can find that makes sense as to what is needed in many cases or any real event type system.
Hmm I guess that the system discussed is in place, regarding 2.80 at least
developer blender org T63157