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

UXP Plugin: A command that runs automatically when the plugin starts

Participant ,
Sep 19, 2023 Sep 19, 2023

Copy link to clipboard

Copied

Some questions for the UXP developers about presetting the plugin.
Let's assume that the plugin should build a separate submenu on the main InDesign menu at the start. This is an unconditional action that is executed in every session of the plugin.
The idea is to execute a certain "command" only once at the beginning of a session without user involvement, i.e. programmatically.
The regular menu is more manageable than the list of commands in the plugin panel: items can be disabled depending on the state of the active document, which is not provided in the plugin command panel.
When the plugin exits, a similar automatic command should be executed to destroy unnecessary menu items created by the plugin, etc.

 

TOPICS
Feature request , How to , Scripting , UXP Scripting

Views

339
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
Guide ,
Sep 19, 2023 Sep 19, 2023

Copy link to clipboard

Copied

Read about entrypoints.

Specifically, you need entrypoints.plugin.create and entrypoints.plugin.destroy.

From there it works the same way as in ExtendScript.

To work around the currently missing "$ID/" translation, you can pass objects from ExtendScript.

let scriptPanelMenu = app.doScript('app.menus.item("$ID/ScriptPanelPopup")',ScriptLanguage.JAVASCRIPT);

 

Votes

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
Participant ,
Sep 19, 2023 Sep 19, 2023

Copy link to clipboard

Copied

Thank you, I'm getting distracted... Yes, it really works!

Votes

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 ,
Sep 19, 2023 Sep 19, 2023

Copy link to clipboard

Copied

I am doing that with a plugin currently in development actually. It is possible. However, cleaning up the menu when quitting InDesign has been a challenge. Here’s a helpful note.

Completely remove submenu added by script

Votes

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
Participant ,
Sep 19, 2023 Sep 19, 2023

Copy link to clipboard

Copied

LATEST

It is also advisable to clean the menu immediately before building it. Sometimes the InDesign session crashes and the menu remains. A double cleanse will make it permanent.

Votes

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