Implementing JGoViewEvent.SELECTION_DELET

Im trying to implement a JGoViewEvent.SELECTION_DELETING event handler
on the JGoView to try to stop the user from deleting the label attached
to a link. I want to allow to delete the label only if the link is also
being deleted.


obj = (JGoObject)e.getJGoObject().getTopLevelObject();
if(obj instanceof JGoLinkLabel)

However e.getJGoObject() always returns null. Am I missing a step?

It’s the selection that’s being deleted, not just a single JGoObject.
I think you want to examine the objects that are in the JGoView.getSelection().

I have looked into that. How would I allow certain items to be deleted
while consuming others? I mean right now with e.consume() if I
encounter an item that cannot be deleted the entire delete process is

Well, this is handled in one case: when the selected object is part of a layer that is not modifiable.
But more generally, I think you could just modify the JGoView.getSelection() in your SELECTION_DELETING event handler. Do watch out for modifying the selection while you are iterating over it.