How to raise diagram event?

How do I raise a specific DiagramEvent in GoJS?
I’m asking because I have overridden a function that raises a few of these.

That’s not typical. What are you overriding? Can you call the base functionality with go.Class.prototype.call(this)?

I’m overriding the ungroupselection function since I want a slightly different behaviour… I didn’t try to call the base method, but I think it would mess up what I’m trying to achieve

Rather than avoiding a call to the base method, could you just modify the selection prior to calling it? Or are you changing the functionality extensively?

There is the undocumented function Diagram.raiseDiagramEvent, but it is usually better practice to avoid using it.

You could add:

diagram.raiseDiagramEvent('ChangingSelection');

Then later:

diagram.raiseDiagramEvent('ChangedSelection');
diagram.raiseDiagramEvent('SelectionUngrouped', groups, members);

But like Jon said, it may be best to avoid doing this if at all possible.

Simon, John, thanks for your replies and time :-)
I’d say I’m changing the functionality exntesively, I’m preventing the ungroupSelection from removing the group node from the model, apart from other data manipulations that I do… I was thinking of doing it this way because I thought it would be “the GoJS way”…
But, If it would be better, I don’t actually need to override the ungroupSelection function… as I said, I just thought this would be the GoJS way

I see. Perhaps that’s a reasonable way to do it, but I think from GoJS’ point of view, that’s not really “ungrouping”, its just “moving all the members of the group to the top level” (or “up one level”).

If it works for you, that’s OK though.