Introduction

The default menu bar of BrainStim can be extended by implementing one or more menu configuration files. These files should then be stored inside the Menus subfolder of the Main Program directory (or in one or more subfolders under this directory). The configuration file can have it's own name, but the file type extension must be ini (*.ini).

Example

Let's create a custom menu configuration file:

  1. Start BrainStim.
  2. Create a new document by using the menu File > New > Undefined Document. Save the file inside the Menus subfolder of the Main Program directory (or in one or more custom subfolders by adding these first inside this directory) by using the menu  File > Save As... and then give it a name using the ini (*.ini) extension, like myMenu.ini.
    Alternatively you could also open (File > Open) the file named Example1.ini inside the Menus/Examples subfolder of the Main Program directory. If you choose to do so the you don't need to add the below lines as described in this example below, but only uncomment them by removing the # prefix (except for step 3).
  3. Edit the new document by adding first some commenting lines by adding the prefix # before each of the commented lines like:
    # This file is used for creating some custom toolbar menu entries
    # This line is treated as comment because its prepended with the hash(#) symbol
    # and therefore not used (skipped) for creating the menu entries.

    The first thing we need to do before we can start adding some custom menu entry keys is to add a special group to which all menu entry keys are added. This group should be named CustomMenuActions and is placed between brackets ([]) to mark it as a group like:

    [CustomMenuActions]

    Now we can start adding custom menu entry keys to the group we've just created following this syntax:

    <MenuEntryKeyName>=<MenuEntryType>|<MenuEntryFilePath>|<MenuEntryMenuPath>

    We can see from the above syntax that each menu entry key has a name section that is defined by 3 sections which are separated by a vertical bar (|) sign. The following table explains each section:

    section Description
    MenuEntryKeyName The name of the menu entry key, this name is internally used and can be anything as long ads there are no empty spaces in it and it shouldn't start with a hash (#) sign (because the line would then be commented/skipped). Important! The custom menu items are sorted by this name before they are added to the menu, so if two item are added to the same (sub)menu then you should bear in mind that their name determines the position in the menu.
    MenuEntryType

    This section specifies the type of the menu entry, the type can be:

    • MenuItem: defines that this custom menu entry should only be added to the menu and no further action needs to be taken when this custom menu entry is clicked. The MenuEntryFilePath section should be left empty.
    • ScriptPath: defines that this custom menu entry refers to a script file that is automatically executed when this custom menu item is clicked. The MenuEntryFilePath section should contain the file path of the script file.
    MenuEntryFilePath Depending on the MenuEntryType (see above) this can be left empty or contain a relative or absolute file path. Important! a specified file path should either have a forward-slash (/) character or double back-slashes (\\) characters for each directory separator.
    MenuEntryMenuPath This defines the resulting menu path architecture for the new custom menu entry, each level should be specified by using a forward-slash character and starting from the top menu going down to the custom menu entry. Sub-menu's are automatically created if needed. You can also add a horizontal separator (line) in a submenu between menu entries to make a better visual distinction between the entries. You can do this by using the MenuEntryType MenuItem and using a underscore (_) character for the lowest/last level in this MenuEntryMenuPath section, see below for an example.

    Let's add some different custom menu entries:

    CustomMenu_000=ScriptPath|Examples/Scripts/BrainStim/QtScript Functions/Functions.qs|Examples/Scripts/Functions 1

    A relative path (starting from the Main Program directory) to a example script that should be executed when the custom menu entry is clicked.

    CustomMenu_001=MCustomMenu_001=MenuItem||Examples/Scripts/_

    A horizontal menu separator line, no script file.

    CustomMenu_002=ScriptPath|C:/Program Files (x86)/BrainStim/Examples/BrainStim/QtScript Functions/Functions.qs|Examples/Scripts/Function 2

    A absolute path where the directory separator is a forward-slash (/).

    CustomMenu_003=ScriptPath|C:\\Program Files (x86)\\BrainStim\\Examples\\BrainStim\\QtScript Functions\\Functions.qs|Examples/Scripts/Function 3

    A absolute path where the directory separator is a double back-slash (\\).

  4. After saving (CTRL + s) the above changes to the document we need to restart BrainStim to see the result of the above. Notice the BrainStim 'default' OutputLog Tab for changes when clicking the menu entries.