This is an old revision of the document!


Extending the Menus of the CARA Explorer

The following code adds a new menu to the menubar of the CARA Explorer; the menu contains one item which calls a Lua function if triggered by the user.

gui.explorer:getMenuBar():addMenu(“Test”):addAction(“Say Hello”, function() print(“Hello!”) end )

You can also add menu items to the context menus; you can access the context menus by the title shown in the navigation tree; the following example adds an item to the context menu of the Spectra pane:

gui.explorer:getPopup(“Spectra”):addAction(“Print Name”, function() print(gui.selected:getName()) end )

Notice the selected attribute; it is automatically set by the explorer to the current item selected by the user. If you select a spectrum in the Spectra pane, selected points to a Spectrum object. If you select a spin or system in the Systems pane, selected points to a corresponding object.


Personal Tools