Creating Menus Dynamically


Is there a way to dynamically specify a Menu?

My use case is that I’d like to add the ability to generate specific kinds of files. I’d like to have a generic file-creation package, and have other packages provide the specific kinds of files that can be created. (For example, one package might create files for iOS development, and another might create files for Android development.)

Ideally, the generic file-creation package would create the top-level “Create New File” menu item, and the sub-menus would be specified by the other packages. The current API for menus ( seems to just support a single package specifying an entire menu item and sub-menus.

This is not a show-stopper (I could specify the menu in a package that knows about all of the other packages), but it would be nice to have an API for this.


The answer is yes, there’s a way: