Author Topic: JavascriptAddin using session.prompt causes EA to freeze  (Read 1158 times)

meeert

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
JavascriptAddin using session.prompt causes EA to freeze
« on: April 21, 2023, 04:43:35 pm »
Hi, the titles says it already.

I made the standard Example of the JavascriptAddin. However, the following behavior makes EA freeze.

EA_MenuClick

     Session.Prompt("You clicked " + ItemName, 1);

Not the intended behavior I assume?
I'm using version 16.1.1625 - 64 bit
« Last Edit: April 21, 2023, 05:14:31 pm by meeert »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8018
  • Karma: +118/-20
    • View Profile
Re: JavascriptAddin using session.prompt causes EA to freeze
« Reply #1 on: April 24, 2023, 08:29:49 am »
The Javascript addins are running their code synchronously with EA, just like add-ins written in other languages.

If you show a message box in any language, the entire UI of the application is blocked, waiting for the call to return.

So yes, based on what you've described that is entirely expected.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1322
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: JavascriptAddin using session.prompt causes EA to freeze
« Reply #2 on: May 22, 2024, 07:44:28 pm »
Hi,

I'm having the same issue when calling Session.Prompt from a model-based addin.
Whilst I understand the addin is waiting for the user to click on a button e.g. OK, Yes, No... EA freezes for a few minutes preventing the user from doing anything.
Is there a workaround (code to add) to prevent this behaviour ?


Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


philchudley

  • EA User
  • **
  • Posts: 728
  • Karma: +19/-0
  • UML/EA Principal Consultant / Trainer
    • View Profile
Re: JavascriptAddin using session.prompt causes EA to freeze
« Reply #3 on: May 23, 2024, 05:54:22 pm »
Hi

Yes me too!

I developed a Model based Add-in which uses Session.Prompt in addition to Session.Output

Both "freeze" with the "blue circle of death" ... eventually EA will respond to the user click, say OK in the Session.Output.

I have found, that when "freeze" happens, clicking the EA title bar, springs EA back into life and the user interact with the dialog. Not ideal.

As this was for a client, I reverted to write the addin as a conventional C# dll

Phil
follow me on Twitter

@SparxEAGuru

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1322
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: JavascriptAddin using session.prompt causes EA to freeze
« Reply #4 on: May 23, 2024, 11:10:24 pm »
Hi Phil,

Thanks for confirming the behaviour. Until this can be fixed, there could be a workaround involving a custom Javascript function to replace the Session.Prompt.

Update: I confirm that using a simple Javascript function fixed the issue.
Code: [Select]
//style:
// 0 -> OK button
// 1 -> OK/Cancel buttons
// 3 -> Yes/No/Cancel buttons
// 4 -> Yes/No buttons
// Returns a value matching the clicked button:
// 1 -> OK
// 2 -> Cancel
// 6 -> Yes
// 7 -> No

style += 4096;
var WSH = new COMObject("WScript.Shell");
return WSH.Popup(prompt, 0, title, style);

I published an article about a Model Based Addin example: https://www.umlchannel.com/en/enterprise-architect/item/359-enterprise-architect-model-based-addin

« Last Edit: May 29, 2024, 04:15:12 pm by Guillaume »
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com