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

Item position with addMenuItem

Community Expert ,
Mar 26, 2024 Mar 26, 2024

Hi,

I think I understood the nPos parameter of the app.addMenuItem method, and if several scripts have the same parameter the last item loaded take the place of the previous one.

But I wonder in which order the different .js files of the "JavaScript" folder are loaded to know which is the last one and see if it actually takes the last position indicated. I did several tests and it seems it's not the alphabetical order...

Thanks.

@+

TOPICS
JavaScript , PDF
271
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Mar 26, 2024 Mar 26, 2024

The order in which scripts are loaded is not predictable, except that app scripts are loaded before user scripts, and plug-ins are loaded before any script.  The script that is adding a menu item would need to examine the existing menu order before determining the insert location. 

The nPos parameter can also be the name of an existing menu item, it doesn't have to be a number. 

However, I have found that trying to force a menu item position to be problematic to the point that it is not worth the effort.  And things have gotten worse with new UI. 

 

 

  

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

Translate
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 ,
Mar 26, 2024 Mar 26, 2024

The order in which scripts are loaded is not predictable, except that app scripts are loaded before user scripts, and plug-ins are loaded before any script.  The script that is adding a menu item would need to examine the existing menu order before determining the insert location. 

The nPos parameter can also be the name of an existing menu item, it doesn't have to be a number. 

However, I have found that trying to force a menu item position to be problematic to the point that it is not worth the effort.  And things have gotten worse with new UI. 

 

 

  

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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 ,
Mar 26, 2024 Mar 26, 2024
LATEST

OK, Thanks!

Translate
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