Differences

This shows you the differences between two versions of the page.

extending_the_menus_of_the_cara_explorer [2015/09/16 19:00]
rkeller created
extending_the_menus_of_the_cara_explorer [2015/09/16 19:00] (current)
rkeller
Line 3: Line 3:
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. 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",+''Lua> gui.explorer:getMenuBar():addMenu("Test"):addAction("Say Hello",
  function() print("Hello!") end )''   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: 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",+''Lua> gui.explorer:getPopup("Spectra"):addAction("Print Name",
  function() print(gui.selected:getName()) end )''   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. 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