On 19/07/2017 at 11:21, xxxxxxxx wrote:
Thanks Andreas, your answer indirectly pointed me to MSG_DOCUMENTINFO_TYPE_SETACTIVE, which seams to be the "magic solution".
What I was trying to achieve was to track the current active object. For this I am using a MessageData plugin, and processing the EMSG_CHANGE. For each incoming EVMSG_CHANGE I check if the current active object's GUID is identical to the stored value. When value is different I know a different object is being selected, I then trigger the necessary data and store the current object's GUID, and keep listening to EVMSG_CHANGE. This seemed to work, except when user selects "Revert to saved ..." since the GUID is the same as before nothing got triggered.
I have now investigated this MSG_DOCUMENTINFO in a SceneHookData and noticed that when a scene is loaded (or a new one is created) the SceneHook::Init can get called to 4 times. While MSG_DOCUMENTINFO_TYPE_LOAD can be posted twice. Wanting to limit the triggering, I looked for an alternative solution.
Then I noticed that MSG_DOCUMENTINFO_TYPE_SETACTIVE only is posted once in any situation. Using this to know when the GUID of the current object can be the same as the stored one, while still need to trigger as a result of "change" in object (if you know what I mean) seems to be the solution.
AND I also get notified when the user switches document ... for free.