Author Topic: Running element script, what did I right-click on?  (Read 2681 times)

HLidstrom

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Running element script, what did I right-click on?
« 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.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Running element script, what did I right-click on?
« Reply #1 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

HLidstrom

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: Running element script, what did I right-click on?
« Reply #2 on: November 09, 2019, 01:59:36 am »
Thanks Geert! That worked like a charm!
(There is so much to learn in Sparx EA)