1.2.1 Putting an X-Function in the Product Menu

Putting an X-Function into the Origin menu involves the following two steps:

Then, in the menu, choose Preference: Menu: Full Menus, or restart Origin to auto-scan the changes for all X-Functions and add the newly added X-Function to the menu. Please refer to X-Function Builder's documentation for more details.

Contents

Setup in Tree View

To make your X-Function show properly in the menu, the following settings in X-Function Builder are required:

  1. Open the X-Function in X-Function Builder.
  2. Switch to Tree View mode, in the Usage Context branch.

Menu Accessible

Once the X-Function is set up in Tree View, you can put the X-Function into the specified menu. Origin enables the user's X-Function to be accessible from the two kinds of menus:

(This mechanism has a few limitations: you need to put the X-Function into the specified file folder, and the X-Function name needs to follow the specified prefix. Also, it is not easy to control its location in the menu. The next mechanism, a user defined menu, will solve all these problems.)

Default Menu

X-Functions are accessible from a specified default menu if they are saved in the proper sub-folder of the X-Functions folder under the User folder.

Folder Menu
Signal Processing\ Analysis: Signal Processing
Spectroscopy\ Analysis: Spectroscopy
Mathematics\ Analysis: Mathematics
Statistics\ Statistics
Folder Prefix Menu
Import and Export\ imp* File: Import
exp* File: Export
Data Manipulation\ w* Worksheet
col* Column
Database Access\ db* File: Database Access

User Defined Menu

In addition to adding X-Functions to default menus, the user is able to put X-Functions into user-defined menus by editing the XML files under the OriginExePath\Themes\Menus folder. There are two XML files under this folder: ConfMenus.xml is used to control the Origin main menu, and ContextMenus.xml is for the context menu.

Example

The following is a complete example that shows how to add a user-defined X function to a new sub menu, OC Guide Tools, under Origin's Analysis main menu. The user-defined menu is the mid in Analysis:Fitting and Analysis:Signal Processing.

  1. Create a folder OC Guide under the path <User Files Folder>\X-Functions\.
  2. Create a user-defined X function following this example, but name it as MyAnalysis and make sure it is saved under the path <User Files Folder>\X-Functions\OC Guide\.
  3. Open the MyAnalysis X-Function in X-Function Builder. Switch to Tree View, in the Usage Context branch, set Menus as Main Menus, check the Windows check box, and check the Worksheet check box under the Windows branch.
  4. Type some text into the Description edit box, for example, "&Custom Dialog". & is used to access the quick selection menu with the keyboard. Click Save to save changes to the X-Function and close X-Function Builder.
  5. Open ConfMenus.xml in an XML editor, for example, XML Marker.
  6. Choose wks -> wksAnalysis -> wfit in the left panel.
  7. Copy the following and paste it into the right panel after <wfit...></wfit>, then click Save.
    <testmenu1 Label = "OC Guide Tools" popup = "1">
            <efg Label = "">
                <name>*</name>
                <auxopts>2162688.</auxopts>
                <catsubcat DataID = "74">OC Guide</catsubcat>
            </efg>
    </testmenu1>
    
  8. Close Origin and restart. Activate a worksheet and, in the menu, choose Analysis. Menu Test:Custom Dialog will display.
    Ocguide xf put to menu.png