How to add a new main menu on top?

How to add a new main menu? not a menu item to an existing menu( like Edit or Help 、File ),I don’t want to change the source code,Can I use extensions to implement this functionality?

Thank you very much for your help

I used ‘registerMenus’ can do this:

Thanks,I’ll try

@feng-sword in order to add additional menus (main-menu, sub-menus, and context-menus), you can create a new theia extension which contributes the functionality. In your case, you’re interested in a main-menu (parent most menu in the application).

We have many examples in the source-code (including an example under @theia/api-samples specifically for menus which should be the easiest example to follow. (these exactly add a main-menu entry:

If you’re looking to creating an extension quickly and easily I’d suggest using our theia-extension-generator.

I hope this helps!

I edited a simple demo add one menu,it is ok,but it‘s don’t show in browser when i copy files from api-sample floder to my own custom extension ,recompile and run this extension,i don’t see ‘sample-menu’,why?I’ve been working on other languages before,theia is a little difficult at first for me,Thanks for your help

@feng-sword do you have the project hosted anywhere (ex: a public github repository) so I can take a look?

@vince-fugnitto this is github repository path

@feng-sword here is a very simple main menu contribution (labeled as hello world) that you can use/review:

@vince-fugnitto This demo I successed in yesterday ,

I just use theia/api-samples failed,But I really appreciate your help :smiley:

There has a problem , menu sort will failed when order > 9(ex: order: ‘10’),the new menu will show in first location,because the last menu id is ‘Help’ and it’s order = 9, maybe there code has some probelme,Hopefully this problem can be fixed.

@feng-sword the order is a string and it is sorted alphanumerically:

That is the reason why the string 10 comes before 9.

1 Like

wow, The order is string was overlooked by me,new menu’s order: ‘9a’ is ok,thanks :stuck_out_tongue_closed_eyes:

1 Like