On 14/11/2017 at 05:44, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R19
Platform: Windows ;
Language(s) : C++ ;
---------
I mention the original topic for informational purpose only:
https://plugincafe.maxon.net/topic/9903/13344_how-to-detect-undo-&KW=&PID=52915#52915
In the past I used a MessageData plugin to listen to EVMSG_CHANGE to detect changes in polygon selection performed by the user.
class TestMessageData : public MessageData
{
public:
virtual Bool CoreMessage(Int32 id, const BaseContainer &bc);
UInt32 mLastDirtyChecksum;
};
Bool TestMessageData::CoreMessage(Int32 id, const BaseContainer &bc)
{
// to detect if user has changed polygon selection we listen to EVMSG_CHANGE,
// and skip processing any other message
if (id != EVMSG_CHANGE)
return true;
BaseDocument* doc = GetActiveDocument();
if (!doc)
return true;
BaseObject* object = doc->GetActiveObject();
if (!object || !object->IsInstanceOf(Opolygon))
{
mLastDirtyChecksum = 0;
return true;
}
// !!! simplified detection of change of polygon selection !!!
UInt32 objectDirty = object->GetDirty(DIRTYFLAGS_SELECT);
if (mLastDirtyChecksum != objectDirty)
{
mLastDirtyChecksum = objectDirty;
// if 'undo' then bail out, else perform the action ...
When user has made selection changes and then presses the undo button, this triggers the detection twice with increasing dirty values. As such, there is no way to know if a change was the result of a direct user action, or as a result of an undo.
Since undos cannot be detected from a MessageData, I am thus looking for an alternative solution to detect selection changes, only resulting from user interactions.
Using a SceneHookData I could detect the undo, but I see no way to combine the two (detect selection changes + detect undo) to omit detecting the selection changes as a result of undos.
Thanks,
Daniel