Author Topic: Programmatically adding menus  (Read 5554 times)

murali

  • Community Member
  • Posts: 31
  • Hero Points: 0
Programmatically adding menus
« on: July 30, 2009, 02:10:02 AM »
Hi,

How can I add a menu list programatically? I see that we can do _menu_insert and add menu items one by one, but that seems to be a tedious approach..

In the document, a sample menu was given as follows:
Code: [Select]
_menu mymenu {
  submenu "&File", "Help file menu", "Displays File drop-down menu", "ncw" {
      "&New", "new", "ncw" , "help new", "Creates a new file to edit";
      "&Open\tCtrl+O", "gui_open", "help gui_open", "Open a file";
  }
  submenu "&Edit", "Help edit menu", "Displays Edit drop-down menu","ncw" {
      "Cu&t", "cut", "sel|nrdonly", "help cut", "Deletes the selection and copies it to the clipboard";
  }
}

Is there an API that I can use to add it to _mdi_menu programatically with just one call?

thanks in advance.
Murali

murali

  • Community Member
  • Posts: 31
  • Hero Points: 0
Re: Programmatically adding menus
« Reply #1 on: July 31, 2009, 05:21:40 PM »
Is it do-able at all? Looking at the macro environment's richness, I thought it would just take a single API call to do that just like we add toolbars programmatically using tb_addform.

Murali

Graeme

  • Senior Community Member
  • Posts: 2821
  • Hero Points: 347
Re: Programmatically adding menus
« Reply #2 on: July 31, 2009, 11:33:53 PM »
You could try _menu_insert_submenu but I'm not sure why you think _menu_insert is tedious.  I guess _menu_insert_submenu is useful when you have an existing menu that you want to add to different places.  If you want to try something messy, you could use insert_object to insert the _mdi_menu into a temp buffer, then programmatically edit the temp buffer to change the menu and re-load it.

Graeme

murali

  • Community Member
  • Posts: 31
  • Hero Points: 0
Re: Programmatically adding menus
« Reply #3 on: August 03, 2009, 05:49:50 PM »
I was just trying to avoid adding code to generate each menuitem. But looks like there is no easy way as you had pointed out. Finally I used .e sample file that someone had posted in http://community.slickedit.com/index.php?topic=1232.msg11836#msg11836 and it works like a charm. Now I am able to get menus up and running for my macros.

thanks,
Murali