Custom Menus

You can add your own menu items to many Igor menus by writing a menu definition in a procedure window. A simple menu definition that adds two menu items to the built-in Macros menu looks like this:

Macros menu with Load Data File... and Do Analysis menu items

You can add new menus on the menu bar (they'll appear after the regular Igor menus but before the Help menu) simply by specifying a menu name that doesn't already exist. You can add submenus, too:

Custom top-level MyMenu menu with a Process submenu containing three menu items

Custom Contextual Menus

You can add a custom contextual menu to a graph, panel, table, or layout window, though it takes a little bit of programming. Here´s the code that implements a contextual menu that "selects" a graph trace by increasing its line width:

Page of code showing the AllowSelectionInTopGraph and ContextualWindowHook functions

Once the AllSelectionInTopGraph function is called, the top graph will send events to the ContextualWindowHook routine. When a mousedown event is detected, the code checks if it is a right-click (on PC or Mac OS X) or a control-click (on Macintosh) near a graph trace. If it is, the code pops up a menu using the PopupContextualMenu operation:

Graph showing the contextual menu with Select and DeSelect menu items

If the user chooses the "Select" menu item, the trace that was clicked on is then displayed with a thick line.

Graph showing the red trace displayed with a thicker line than the blue trace

"Deselect" returns the trace to the default thin line. In a real application additional means for recording selected traces would allow processing of the selected trace(s).