Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: HLidstrom on November 02, 2019, 04:58:35 am

Title: Running element script, what did I right-click on?
Post by: HLidstrom on November 02, 2019, 04:58:35 am
I can't be the first to ask this, but I guess I'm using the wrong search strings.

So I wrote an element script. Works fine when I select an element in the project browser.
However, the script is also available when I right-click on an element shape on a diagram and that has unintended consequences.
Selecting a shape is not the same as selecting the corresponding element in the browser, so how do I test for what I right-clicked on? If I new I could take action and write the code to select the element behind the shape.
I am on Sparx EA 14.
Title: Re: Running element script, what did I right-click on?
Post by: Geert Bellekens on November 02, 2019, 05:36:46 pm
You can use Repository.GetContextObject()

This works both in the project browser as in a diagram

Geert
Title: Re: Running element script, what did I right-click on?
Post by: HLidstrom on November 09, 2019, 01:59:36 am
Thanks Geert! That worked like a charm!
(There is so much to learn in Sparx EA)