Book a Demo

Author Topic: GetContextItem reports incorrect element  (Read 3182 times)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
GetContextItem reports incorrect element
« on: July 31, 2013, 10:53:41 pm »
The operation Repository.GetContextItem doesn't always return the correct object.

When you first select something in a diagram, and then directly right click on an operation in the project browser then GetContextItem returns the owner element of the operation iso the operation.
GetTreeSelectedItem does work correctly in such a situation.

My workaround for the EA_GetMenuItems:
Code: [Select]
           EA.ObjectType selectedType;
            Object selectedItem;
            if (Location == "TreeView")
            {
                //sometimes EA doesn't correctly returns the selected item using GetContextItem when right clicked in Project browser.

                selectedType = Repository.GetTreeSelectedItem(out selectedItem);
            }
            else
            {
                selectedType = Repository.GetContextItem(out selectedItem);
            }

Will report to sparx as well.

Geert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: GetContextItem reports incorrect element
« Reply #1 on: August 02, 2013, 04:11:30 pm »
Very much related to this, but still a bit different.

When you have a sequence diagram with a message and a fragment, and the bottom of the fragment is pretty close to the position of the message.
Then select the message and right click on it.
When you then do a GetContextItem in the EA_GetMenuItems EA will return the fragment in stead of the message, althoug the message is still selected, and the mouse hasn't moved.

The workaround is to make the fragment a bit larger so it' bottom is a little bit further away from the message.

Geert