Deleting Items
The easiest way to control which items should be deleted is setting the deletableItems or deletablePredicate property as mentioned in the Deleting Items section. For example, the following code snippet will prevent nodes from being deleted when they still have edges connected to them:
Alternatively to setting the deletablePredicate property you can also override the shouldDelete method from which you can also access other protected members of GraphEditorInputMode.
Note that the shouldDelete method in its default implementation delegates to the deletableItems and deletablePredicate properties. The latter is used to constrain the former.Overriding the method without taking into account those properties means that they are ignored for whether items are considered deletable. However, deletableItems is still used as a shortcut to decide whether the DELETE command should be enabled or not.
The deleteSelection method is called in response to the DELETE command and actually deletes the selected items after querying the shouldDelete method for every item. It also raises the events listed below. You can customize the entire process by overriding this method.
Event | Occurs … |
---|---|
The shouldDelete method may be called more than once for the same item.