No SelectionDeleting event when calling remove


If I call Diagram.remove() on a go.Link, the Diagram’s SelectionDeleting event is not fired. If I delete that same link with the Del key, I do get SelectionDeleting.

Is this on purpose?


Yes, that is intentional. The SelectionDeleting/SelectionDeleted events apply to “user” deletions – basically when CommandHandler.deleteSelection or cutSelection is called. CommandHandler.deleteSelection calls Diagram.removeParts which calls Diagram.remove.

But if your code is calling Diagram.remove, you could also decide to call your SelectionDeleting listener’s functionality beforehand and decide whether to continue, couldn’t you?

OK I understand. About using the functionality of SelectionDeleting when I call Diagram.remove, this is indeed what I am currently doing.