Skip to main content
bebarth
Community Expert
Community Expert
March 26, 2024
Answered

Item position with addMenuItem

  • March 26, 2024
  • 1 reply
  • 391 views

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.

@+

This topic has been closed for replies.
Correct answer Thom Parker

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. 

 

 

  

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
March 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 PDFScriptingUse the Acrobat JavaScript Reference early and often
bebarth
Community Expert
bebarthCommunity ExpertAuthor
Community Expert
March 26, 2024

OK, Thanks!