Book a Demo

Author Topic: v15.2 - Can I get the right-click selected object via API?  (Read 4698 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
v15.2 - Can I get the right-click selected object via API?
« on: September 23, 2020, 03:06:35 pm »
A number of the shape collection functionalities (alignment, sizing etc.).  Work on the basis of select a collection of diagram items THEN with the right-click function, you can select the functionality and say "like this one!".  For example, "centre horizontally" - like this one or "same height and width" - like this one.  Is it possible through the API to get that right-click selected?

TIA,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: v15.2 - Can I get the right-click selected object via API?
« Reply #1 on: September 23, 2020, 03:53:16 pm »
Not explicitly I think.

But I would check if the order of selected elements helps you at all.
Maybe the first or the last one is always the one that you right clicked on?

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: v15.2 - Can I get the right-click selected object via API?
« Reply #2 on: September 23, 2020, 04:20:07 pm »
There are multiple ways. The key is that EA maintains a context, which is always a single element. You see its properties in the docked windows.

Repository.GetContextItem and Repository.GetContextObject give you access to that object.

Personally, I would be using Repository.CurrentSelection, which should tell you.

Context should be the same element EA is showing in docked windows, and be set during right click. The entire selection is available in the List and ElementSet members.

Finally, EA_OnContextChanged should be called for the one that was clicked on. If you remember that before your other function is called you will know which one is context.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: v15.2 - Can I get the right-click selected object via API?
« Reply #3 on: September 23, 2020, 04:52:01 pm »
There are multiple ways. The key is that EA maintains a context, which is always a single element. You see its properties in the docked windows.

Repository.GetContextItem and Repository.GetContextObject give you access to that object.

Personally, I would be using Repository.CurrentSelection, which should tell you.

Context should be the same element EA is showing in docked windows, and be set during right-click. The entire selection is available in the List and ElementSet members.

Finally, EA_OnContextChanged should be called for the one that was clicked on. If you remember that before your other function is called you will know which one is context.
Thanks Eve,
are all these available from a simple script (such as a .vbs script)?

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: v15.2 - Can I get the right-click selected object via API?
« Reply #4 on: September 23, 2020, 05:03:13 pm »
There are multiple ways. The key is that EA maintains a context, which is always a single element. You see its properties in the docked windows.

Repository.GetContextItem and Repository.GetContextObject give you access to that object.

Personally, I would be using Repository.CurrentSelection, which should tell you.

Context should be the same element EA is showing in docked windows, and be set during right-click. The entire selection is available in the List and ElementSet members.

Finally, EA_OnContextChanged should be called for the one that was clicked on. If you remember that before your other function is called you will know which one is context.
Thanks Eve,
are all these available from a simple script (such as a .vbs script)?

Paolo
Nope, EA_Onxxx are events that are only available for add-ins.
Alternatives for a compiled add-in are the new model-addins, or my EA-Matic add-in.

Geert

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: v15.2 - Can I get the right-click selected object via API?
« Reply #5 on: September 24, 2020, 08:15:20 am »
[SNIP]
Nope, EA_Onxxx are events that are only available for add-ins.
Alternatives for a compiled add-in are the new model-addins, or my EA-Matic add-in.

Geert
That's what I thought, Geert, thanks.

I might "dip my toe in the water" with the model -addins on this one.  It should be simple enough  ;)

I want to use this functionality to allow me to set a pile of User Selected Diagram Properties (USDPs) to a collection of items.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: v15.2 - Can I get the right-click selected object via API?
« Reply #6 on: September 25, 2020, 09:24:28 am »
I might "dip my toe in the water" with the model -addins on this one.  It should be simple enough  ;)
Should be. There's a template package containing signals matching all the calls EA will make, you drop them onto your class and implement them.

Things that I am aware of... Return types aren't in the signals because they don't do that. They should be in the notes and in the official documentation.

Reference parameters. Because of the way Javascript works, EA needs to wrap them in an object to allow values to be returned. The problem is that more things are passed by reference than are indicated in the docs. We are working on how to include that information but it's not there yet.

There's no debugging capability because it's part of EA's flow.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: v15.2 - Can I get the right-click selected object via API?
« Reply #7 on: September 25, 2020, 09:54:12 am »
I might "dip my toe in the water" with the model -addins on this one.  It should be simple enough  ;)
Should be. There's a template package containing signals matching all the calls EA will make, you drop them onto your class and implement them.

Things that I am aware of... Return types aren't in the signals because they don't do that. They should be in the notes and in the official documentation.

Reference parameters. Because of the way Javascript works, EA needs to wrap them in an object to allow values to be returned. The problem is that more things are passed by reference than are indicated in the docs. We are working on how to include that information but it's not there yet.

There's no debugging capability because it's part of EA's flow.
(my emphasis)
OH...
So, heavy instrumentation from day one?

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!