Creating *actual* custom commands with BaseToolbar

Discussion created by kyanuk1 on Jun 9, 2014
Latest reply on Jun 23, 2014 by robby.maddox

I am in the process of creating a toolbar containing nested menus with buttons and other menus for access of some custom functionality for end users. 

For whatever reason, since the ArcMap addin templates do not seem to allow a toolbar contained menus with nested submenus, I turned to the non-addin approach of creating a BaseToolbar which has the ability to add commands (menus, buttons, etc.):

public MyToolbar()

where ButtonItem is a class which inherits BaseCommand:

public class ButtonItem : BaseCommand
     // ...

What I really want these buttons to do is have some non-ESRI functionality (which none of the examples provide), for example, when clicked, retrieves some id, name, or caption of this button, and traverses a directory on the file system to add a new layer to the map, or create a config .xml file somewhere on the file system.

However, there seems to be no room to add any custom methods or properties to ButtonItem, since the method AddItem() of the base toolbar does not take an instantiated object, but either a progid, or class type. 

How can I handle the onClick method of this specific button to access class properties?  There does not seem to be a clear indication of how/when the constructor and onCreate methods are executed.

Does anyone have experience utilizing this toolbar/menu style, or know how to dynamically add nested menu items to an add-in toolbar (loop over a directory, and add a menu item for a folder, or a button item for a file)?