My addin is looking at elements being added to a diagram, and responding to the broadcast events, but I seem to be getting a duplicate event.
(these test cases were done is a simple 'hello world' addin, with no additional function)
In the simple scenario, all is well:
Drop an element into a diagram, and the events are: (all return 'true' to EA)
- EA_OnPreNewElement (just provides the type of element being added, and the diagram ID.) The real addin does some checking here, and returns TRUE when it's OK. In this test, always responds TRUE
- EA_OnPostNewElement - now we have the actual element ID
- EA_OnPreNewDiagramObject - ElementID and diagram ID provided
- EA_OnPostNewDiagramObject- Element ID and diagram ID again
Prefect, and exactly as I expected.
Now change the 'pre diagram object' event to reject this element, so it returns 'false', and we get:
- EA_OnPreNewElement (just provides the type of element being added, and the diagram ID
- EA_OnPostNewElement - now we have the actual element ID
- EA_OnPreNewDiagramObject - ElementID and diagram ID provided - Return FALSE to reject the element
But wait - there's more!
I now get ANOTHER 'EA_OnPreNewElement' event, with the same parameters as before: type & stereotype of the element, and the diagramID.
This is (1) unexpected and (2) a problem.
When the extra event is received, the same code runs as on steps(1) above, and it returns TRUE, which causes an EA error:
'Unknown/illegal base type (UseCase)
Command: UML::UseCase'
(UseCase is just the type i'm using to test this)
..and I can't suppress this message.
I've been trying all day to work out (1) why I get a duplicate event and (2) how to detect that I'm getting a duplicate event, and respond with 'false' the second time around.
So far all solutions are horrible, and are not reliable anyway.
Can anyone suggest why I'm getting the second 'On_Pre_Element' event? Is this a bug? Or a feature ?
Thanks
Ian