pvAddSubMenu()

Adds a submenu.

This function is for use in the projectView.ctl file only (wincc_oa_path/[Version]/scripts/gedi/projectView.ctl). It is not advised to overwrite the original file, because this is effective WinCC OA wide. Instead, copy the original file to your project directory and make changes there. Thus the changes will only have an effect project-wide.

Synopsis

int pvAddSubMenu(string label, string id, [, mapping options]);

int pvAddSubMenu(string label, string id, string parent [, mapping options]);

Parameters

Parameter Description
label Label that is shown in the manu after right mouse-click.
id An internal identifier with which you can address this submenu as parent.
parent The submenu into which it shall be placed (empty string means the main popup).
options A mapping containing additional options as key-value pairs:
"icon" - string This is the same as the parameter "icon" before, so it can be included in the mapping.
"inSubproject" - bool

By setting this value to true, the entry is also shown in the subprojects.

The default remains as before: The entries are only shown in the project.

"category" - string

Defines on which categories of a project an entry will be shown. The possible values are the following strings:

  • CAT_NONE (no category)
  • CAT_SCRIPTS
  • CAT_LIBS
  • CAT_MSG
  • CAT_PICTURES
  • CAT_PANELS
  • CAT_COLORDB
  • CAT_DATA
  • CAT_CONFIG
  • CAT_DPLIST
  • CAT_PROJECT (addresses the project root node in the project tree)
  • CAT_ALL (This combines all of the above categories. Note: This includes CAT_PROJECT)

Note that these are string values, so they have to be used as such:

makeMapping("category", "CAT_PANELS");

The strings are flags so they can be combined with the "|" character in the string, e.g.

makeMapping("category",
                                    "CAT_PANELS|CAT_SCRIPTS");
"filesOnly" -bool If this value is "true", this entry will only be shown for files but not for directories
"parent" - string

This key and following value tell into which submenu it shall be put.

E.g.: makeMapping("parent", "sub1")

"projectLevels" - dyn_int

Defines the numbers of the project levels for which this entry shall be used.

The level number is as usual from 1 .. SEARCH_PATH_LEN-1 (where 1 is your project and SEARCH_PATH_LEN-1 is the installation)

For an example look into wincc_oa_path/scripts/gedi/git.ctl

Since we already have a similar key named "inSubproject", the following rule applies:

Since we already have a similar key named "inSubproject", the following rule applies:

  • coarse implementation: not using "projectLevels" but "inSubproject" (== all subprojects)
  • or fine grained implementation: "projectLevels" specifically defines in which levels an action is allowed.

Return value

In case of errors, the function returns -1 otherwise, 0.

Error

Missing or wrong arguments

Description

The function adds a submenu in the context menu for the project view.

When a submenu is not shown due to its options, all actions and submenus included in it will also not be shown.

EXAMPLE

The following example demonstrates how to add two submenus in the project view.

main()
{
  pvAddSubMenu("a subMenu", "sub1", makeMapping("icon", "red_circle.png", "inSubproject", true));
  pvConnect("rmb", "some action 1", makeMapping("parent", "sub1"));

  pvAddSubMenu("another subMenu", "sub2", "sub1", makeMapping("filesOnly", true));
  pvConnect("fileAdded", "some action 2", makeMapping("parent", "sub2"));
  pvAddSeparator("sub2");
  pvConnect("fileAdded", "some action 5", makeMapping("parent", "sub2"));

  pvConnect("fileRemoved", "some action 3", makeMapping("parent", "sub1"));
  pvConnect("fileRemoved", "some action 4");
  pvConnect("rmb", "in subproj", makeMapping("parent", "sub1", "inSubproject", true));
}

Availability

UI