• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

HTML panels - startup order

Contributor ,
Apr 10, 2021 Apr 10, 2021

Copy link to clipboard

Copied

Hi,

 

I am considerig a rewrite of a scriptUI panel as a html panel.

The code currently performs some jsx script in order to populate some fieds of the UI with values from the current document.

With separate client and host scripts starting up, the client might call the host script before it is loaded.

Is there anything the client can do to wait for the host script to load? I have not seen any mention of the problem in the docs

TOPICS
Scripting

Views

225

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Apr 10, 2021 Apr 10, 2021

Copy link to clipboard

Copied

Without going into implementation details, two issues speak to your question:

  1. With your scriptUI version, the user has executed the script, eg. by choosing it from the script menu, but with a CEP panel, the panel code would run as soon as the extension loads (I think) or possibly when it is first made visible. This might be before the user even has a document open. To solve this you'd put a button in your panel to execute the jsx function, which would gather the data and update the panel UI (see next).
  2. When the CEP panel button (described above) executes the jsx code, you can also specify a callback function which will be executed when the jsx code is finished and this function can handle upating the panel UI. The callback can have a payload, which in your case will include the data required to update your UI.

 

User clicks button -> execute jsx specifying callback function -> jsx gathers and returns data from document -> callback function receives returned data and updates panel UI.

 

The CEP panel can be written in ES6 javascript and use any function available to Chrome version 74.

 

Hope that broad overview is helpful.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 11, 2021 Apr 11, 2021

Copy link to clipboard

Copied

Hi,

 

many thanks for your response. I am aware that, once the user has switched habits from closing/reopening the panel to just leaving it in place, everything will be fine.

In fact, the panel version can get notified about changing the active document and reload data.

The question remains open: what happens if the user opens the panel for the first time in a session - or, in other words, can I avoid an extra button that was not necessary with the ScriptUI version

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2021 Apr 11, 2021

Copy link to clipboard

Copied

LATEST

Well, you can put your update code in all the entry points, eg. startup (eg. in the html file so it runs as soon loaded) or, as you mention, in response to a document load event. Actually I think the "documentAfterActivate" event might be called in either case, so try putting your code there first. Other than that, I think you'd have to rely on whatever events CSEvent gives you.

 

If that doesn't cover your requirement, it would help to tell us your ideal trigger for updating your panel. At worst case, you might need a "refresh" button or something like that, which could be hidden if your update code has already run.

 

Edit: I guess there's nothing stopping your CEP code from sort-of 'polling' the document every so often, but I'm not sure if that'd be a good way to go.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines