How to handle object deletion in View


I’m looking for the best way to handle this situation. I have seperate Document and View classes. I need to know when an object has been deleted by a user, but not programmatically. Users can delete my object by using the DELETE key or using a context menu.
Ex: If I call GoView.Document.Clear() I DO NOT want to perform an action. But if a user deletes one or more objects I DO want to perform an action.
I’ve overriden GoView.OnSelectionDeleted() but this does not change all changes. Ex: I have 2 nodes and a link connecting them. I delete 1 node and the link is also deleted. I only receive the event for the node though.
I’ve tried overriding GoDocument.OnChanged() and looking for Hint 903 (RemovedObject) but I haven’t found a way to distinguish between user deletes and programmatic deletes.
Anyone have experience with this?


Handling the GoView.SelectionDeleted event should work. The problem is that it isn’t clear what objects are directly being deleted by the user, because they are in the selection, and those objects that are deleted due to a side-effect. So it isn’t clear whether those deleted-by-side-effect objects are programmatic deletions or not.
Perhaps the easiest solution is to also define a GoView.SelectionDeleting event handler and a GoDocument.Changed event handler. Document changes that have a hint of GoLayer.RemovedObject and that occur between the view’s SelectionDeleting and SelectionDeleted events presumably meet your criterion.