Book a Demo

Author Topic: Problems with Model Add-In Event EA_OnTabChanged parameters  (Read 29885 times)

OJB

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Problems with Model Add-In Event EA_OnTabChanged parameters
« on: October 31, 2025, 07:35:01 pm »
Hi  :)

I'm working with Sparx Model Add-Ins to provide some automation and "GUI extension" to the Sparx EA client.
I assume with Model Add-Ins the already existing Add-In concept is replicated so that I could use the existing reference e.g. for event handling
to execute certain actions after the user switched between diagrams I use the event EA_OnTabChanged which is defined here:https://sparxsystems.com/enterprise_architect_user_guide/17.1/add-ins___scripting/ea_ontabchanged.html
The event provides 3 parameters:
Code: [Select]
Repository (EA.Repository), TabName (String) and DiagramID (Long) - but this doesn't seem to be the case. When I try to output TabName or DiagramID with Session.Output or Repository.WriteOutput TabName and DiagramID are shown as [object Object]
With other events like EA_MenuClick this works fine (e.g. for the String ItemName)
I'm working with Sparx EA V16.1.1628

The example model doesn't cover EA_OnTabChanged, so I hope that I can find some help how to solve this here  :)

Happy Halloween,
Oliver

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Problems with Model Add-In Event EA_OnTabChanged parameters
« Reply #1 on: November 05, 2025, 08:29:14 am »
What that means is that the parameter is passed by reference (Although there's no good reason for it to do that originally, now the reason is to not break existing add-ins)

Javascript passes objects by reference and primitives by value, so the code has wrapped the value in an object.

Use TabName.val and DiagramID.val.

Elpis

  • EA User
  • **
  • Posts: 64
  • Karma: +7/-0
  • Make MDA/MBSE vital.
    • View Profile
Re: Problems with Model Add-In Event EA_OnTabChanged parameters
« Reply #2 on: November 07, 2025, 08:16:50 pm »
What that means is that the parameter is passed by reference [...]
Use TabName.val and DiagramID.val.

The information about passing simple/primitive value parameter as 'boxed' (Javascript [object]) is worth to be included on the doc page, as it is unexpected here.
A know that *.val style of passing simple value parameter is used in scripting EA API as a 'workaround' for some model-addin methods, having [out] kind of parameters (i.e. parameter value being _returned_ from a method). But EA_OnTabChanged is not the case, so boxing a [in] string parameter is misleading and should be described explicitly (if left as-is for backward compatibility reason).