# How to Add Color to Menu Definitions

> Source: https://manual.pvxplus.com/how-to/how-to-add-clr-to-menu-defs

One easy way to update the appearance of a PxPlus application is to define the colors used on Menu Bars. Starting with PxPlus 2024, additional options for defining menu colors are available for both NOMADS and non-NOMADS applications.

## Non-NOMADS Applications

For non-NOMADS applications, menus are created via the **[MENU_BAR](https://manual.pvxplus.com/directives/menu-bar)** directive. The MENU_BAR directive supports the use of parameters, such as LEFT, FILL, TEXT, etc., for defining colors in menus.

If the first character of the menu definition is an **!** (*exclamation point*), or a first or second character of **-** (*dash*) is also specified, then the specified colors will also be applied to the top level menu (the horizontal menu at the top of the window). By default, the color will not apply to the top level menu.

***Example:***

This example creates a menu with a Dark Cyan background and White text:

```
menu_bar 10,"!LEFT(RGB:100,100,100),FILL(Dark Cyan),TEXT(RGB:255,255,255)[&File,&Edit,&Help],F:[&Open,&Save,&Quit],E:[&Add,&Delete],H:[&Version Info]"
```

See **[Menu Colors](https://manual.pvxplus.com/directives/menu-bar#Mark25)** for more examples.

## NOMADS Applications

Colors can be applied to NOMADS menus and popup menus in four different ways. Click the link provided for each method for information on how to use it.

- **[Method 1](https://manual.pvxplus.com/how-to/how-to-add-clr-to-menu-defs#Mark1)**: Application-wide by using NOMADS global variables or NOMADS object properties
- **[Method 2](https://manual.pvxplus.com/how-to/how-to-add-clr-to-menu-defs#Mark2)**: Applying a Menu Bar or Popup Menu Theme
- **[Method 3](https://manual.pvxplus.com/how-to/how-to-add-clr-to-menu-defs#Mark3)**: Defining menu colors in Library Defaults for a specific screen library
- **[Method 4](https://manual.pvxplus.com/how-to/how-to-add-clr-to-menu-defs#Mark4)**: Adding colors to an individual panel menu (and menu items) or applying a Visual Class to a menu in Menu Bar Definition

For information on their order of precedence, see **[Menu Color Hierarchy](https://manual.pvxplus.com/nomads-graphical-application/creating-panel-controls/menu-bar/menu-colors#hierarchy)**.

***Sample Menu***

To demonstrate all of these methods, the sample menu definition below will be used.

It contains the days of the week, which are defined as Menu Groups. Each day has three menu items: am, noon, pm. Simple code has also been added to each item to display a check mark beside the item if it is selected.

![](https://manual.pvxplus.com/migration-assets/c1f1fa9fdd871bff098a453b8d425fc46a16b28cd28e0c108c99475a0e29a249.jpg)![](https://manual.pvxplus.com/migration-assets/fef9e83ae5b621972690f29d8d0dfbdf819c52cda28f3e73a2787f8c6612b651.jpg)

Since no menu colors have been assigned, the menu is using the default Light Gray background with Black text. When the mouse hovers over a selection, it is displayed with White text on a Blue background.

|  |
| --- |
| ![](https://manual.pvxplus.com/migration-assets/bd41069b5ae45ee776f5ab46f3d931ef5cb81f1d5f0c28e690bd471eef2c2cb5.png) |

***Method 1: Using NOMADS Global Variables or NOMADS Object Properties***

Setting NOMADS global variables or NOMADS object properties may be the easiest way to define menu colors application wide. The ones that can be set to affect menu colors are:

| **Description** | **NOMADS Global Variable** | **NOMADS Object Property** |
| --- | --- | --- |
| Menu Text Color | %NOMAD_Menu_Text_Clr$ | %NOMADS'Menu_Text_Clr$ |
| Menu Text Background Color | %NOMAD_Menu_TextBackground_Clr$ | %NOMADS'Menu_TextBackground_Clr$ |
| Menu Left Edge Color | %NOMAD_Menu_LeftEdge_Clr$ | %NOMADS'Menu_LeftEdge_Clr$ |
| Use Menu Color on Top Level Option | %NOMAD_Menu_Top_Option$ | %NOMADS'Menu_Top_Option$ |

These settings are usually made in the **Start_Up** program or by using the **[NOMADS Environment Maintenance](https://manual.pvxplus.com/nomads-graphical-application/maintain-nomads-environment)** utility.

***Example 1:***

Adding the following lines to your **Start_Up** program would result in a menu with Blue text on a Yellow background and a Light Green left edge:

```
%NOMAD_Menu_Text_Clr$="Blue"
%NOMAD_Menu_TextBackground_Clr$="Yellow"
%NOMAD_Menu_LeftEdge_Clr$="Light Green"
%NOMAD_Menu_Top_Option$="Y"
```

***Results in:***

![](https://manual.pvxplus.com/migration-assets/8ecf2c66e218866d19db4e55cb24b6a58caf1441946fa58356dbf3022be3bf90.png)

***Example 2:***

The **NOMADS Environment Maintenance** utility can be used to set the following Menu Bar properties that affect menu colors:

```
%NOMADS'Menu_LeftEdge_Clr$
%NOMADS'Menu_TextBackground_Clr$
%NOMADS'Menu_Text_Clr$
%NOMADS'Menu_Top_Option$
```

These steps show you how to use the **NOMADS Environment Maintenance** utility to set the Menu Bar properties:

|  |  |
| --- | --- |
| 1\. | From the IDE Main Launcher, invoke the **NOMADS Environment Maintenance** utility. See **[Invoking NOMADS Environment Maintenance](https://manual.pvxplus.com/nomads-graphical-application/maintain-nomads-environment#invoking)**. |
| 2\. | The **Maintain NOMADS Environment** window displays. Scroll down the list until *Menu Bar* is displayed in the *Category* column. You should see the four Menu Bar properties mentioned above. |
| 3\. | To set a Menu Bar color property, click the Color Selections (*paint palette*) button in the *Value/Expression* column. The **Color Selections** window displays. Select the color and click *OK*. |
| 4\. | You are returned to the **Maintain NOMADS Environment** window. The selected color displays in the *Value/Expression* column, and the check box in the *Set* column is automatically selected. A description of the selected property also displays below the grid.<br>![](https://manual.pvxplus.com/migration-assets/81d30d9e8e64f4bb43bf9cb2a43f43b0ed439e6de8903a49cee64825ff82f891.png) |
| 5\. | To set the *Menu_Top_Option$* property, click the drop down arrow in the *Value/Expression* column and then choose a value. After that, the check box in the *Set* column is automatically selected.<br>![](https://manual.pvxplus.com/migration-assets/39a492fbc4b52a7d1fdebcbe2c758d1a4a8b5ab63563c69d04d1da96a011f2ad.png) |
| 6\. | Click *OK* to save and exit the utility. |

***Method 2: Applying a Menu Bar or Popup Menu Theme***

A Theme can be defined for Menu_Bar or Popup_Menu control types. Both have similar properties that can be defined; however, the Menu_Bar has one additional property, *Use Color on Top Level* property, which is not applicable to the Popup_Menu.

|  |  |
| --- | --- |
| ![](https://manual.pvxplus.com/migration-assets/5a70c0e9d3f7d7bfdfd54b49f4fbf81db455fa76792e3e3d9a35cb0e22a51738.png) | ![](https://manual.pvxplus.com/migration-assets/f051c1f031cdcc01ce9d84e8b75c340475f8206873fcf7551cb1edc69d596706.png) |

***Example:***

This example shows a Menu_Bar Theme definition and a sample menu with this Theme in effect:

![](https://manual.pvxplus.com/migration-assets/6d00bd471f0829972193cc0955a0aaa70de2f0ee5870304d775473ccbef4747f.png)

These steps show you how to define a Menu_Bar Theme and then apply this Theme to a menu on a specific panel:

|  |  |
| --- | --- |
| 1\. | Invoke the **Themes Maintenance** utility. From the IDE Main Launcher, expand the *Graphical Application Builder (NOMADS)* category, and then expand the *Setup* category. Select *Themes*. |
| 2\. | If the Themes file does not exist, a message will display to ask if you want to create it. If this happens, click *Yes*. |
| 3\. | The **Themes Maintenance** utility is displayed.<br>![](https://manual.pvxplus.com/migration-assets/2289b5549c984b70d7b0530b98cd2c8e22bb05b580339f63477dd7e1e17b5324.png) |
| 4\. | Enter a unique *Theme* name and then press the *Tab* key. |
| 5\. | For *Control Type*, select *Menu_Bar* from the drop down list. |
| 6\. | The grid lists the Menu_Bar properties.<br>![](https://manual.pvxplus.com/migration-assets/5dca1158fd314fb73ea3e2a178017459c79a433e9c7264ded674dc168c24b4fa.jpg) |
| 7\. | To set the *Use Color on Top Level* property, click the drop down arrow in the *Value* column, and then choose a value. |
| 8\. | To set each of the color properties, click the three-dotted button in the *Value* column. The **Color Selections** window displays. |
| 9\. | Select the color and then click *OK*. The selected color displays in the *Value* column. A small triangle shows a sample of this color in the upper left corner of the cell.<br>![](https://manual.pvxplus.com/migration-assets/90ede31e29ac9180ab1c1ca80864bb2c865f57d92c35934cf8ffb565063f25db.png) |
| 10\. | When you are done setting the properties, click the *Write* button. |
| 11\. | A message displays to confirm that the Theme record was updated/added.<br>![](https://manual.pvxplus.com/migration-assets/575a488e37f1ebf1bc7f2ce6a19b2cc1260b9622e66b32642e9af733bc5e4ac0.png) |
| 12\. | A Theme can be applied at several hierarchical levels within an application. See **[Applying a Theme to Your Application](https://manual.pvxplus.com/nomads-graphical-application/system-maintenance-tools/system-options/themes#applyingtheme)**.<br>These next steps show you how to apply a Menu_Bar Theme to a menu on a specific panel.<br>Launch **Library Object Selection** and, in the NOMADS Panel Designer, load the panel that contains the menu definition. |
| 13\. | On the panel menu bar, select *Panel > Header* to launch the **Panel Definition**. |
| 14\. | Click the **Font/Color** tab. |
| 15\. | Under the **Theme** section, click the drop down arrow on the input control and then select the Theme.<br>![](https://manual.pvxplus.com/migration-assets/43401fcb69b081aaf95f065397806419632e437b95867d49a0ea72ed5cd5cf6c.png) |
| 16\. | Click *OK* to save and close the **Panel Definition**. |
| 17\. | Test the panel. Assuming that no other colors are defined for the individual menu, the colors defined in the Menu_Bar Theme are applied. |

***Method 3: Defining Menu Colors in Library Defaults***

Menu colors can also be defined at the **[Library Defaults](https://manual.pvxplus.com/nomads-graphical-application/nomads-development/maintaining-library-objects/library-defaults)** level for a specific screen library. Any menus defined for panels in the screen library or any popup menus defined for the library will use the **Library Defaults** colors unless a Theme is defined or colors are defined for a specific panel.

These steps show you how to define menu colors at the **Library Defaults** level:

|  |  |
| --- | --- |
| 1\. | Launch **Library Object Selection** for a specific screen library. |
| 2\. | Invoke the **Library Defaults** window. This can be done by using one of the following methods:<br>***Method 1:***<br>Select *Library* in the menu bar, and then select *Library Defaults*.<br>***OR***<br>***Method 2:***<br>If using either ***Button View*** or ***Toolbar View*** (on the **Views** menu), click the *Defaults* button. |
| 3\. | On the **Library Defaults** window, select the **Font/Color** tab. |
| 4\. | Under the **Menu Color** section, change each of the following options by clicking the Color Selections (*paint palette*) button, which displays the **Color Selections** window:<br>• For *Background*, select *Dark Magenta* and then click *OK*.  <br> • For *Edge*, select *Light Magenta* and then click *OK*.  <br> • For *Text*, select *Light Gray* and then click *OK*. |
| 5\. | For the *Apply Menu Colors to Top Menu* option, click the drop down arrow and select *Yes*. |
| 6\. | The **Menu Color** selections look like this:<br>![](https://manual.pvxplus.com/migration-assets/95bfdd09aa11e9f8e8cc5c7cb8cc1e842660be0e795356182e26503c31505004.png) |
| 7\. | Click *OK* to save and return to **Library Object Selection**. |
| 8\. | Test the panel. Assuming that no Theme is in effect and no colors are defined for an individual menu, the panel displays as follows:<br>![](https://manual.pvxplus.com/migration-assets/27547bf08de32578831acebaaac950bfe2703ea70c3bc432d905375b98257b13.png) |

***Method 4: Adding Colors to an Individual Panel Menu***

These steps show you how to add colors to a menu on an individual panel:

|  |  |
| --- | --- |
| 1\. | In the NOMADS Panel Designer, load a panel that contains a menu definition. |
| 2\. | Invoke the **Menu Bar Definition** dialog. This can be done by using one of the following methods (depending on which **Designer** menu option is selected):<br>***Method 1:***<br>If using the **[NOMADS+ Toolbar](https://manual.pvxplus.com/nomads-toolbar/introduction)**, click the *Menu* button in the toolbar.<br>***OR***<br>***Method 2:***<br>If using either the **[Folder Style](https://manual.pvxplus.com/nomads-graphical-application/panel-designer/folder-style/using-the-folder-style)** or **[Property Sheets](https://manual.pvxplus.com/nomads-graphical-application/panel-designer/properties-table/overview)** version of the Panel Designer, select *Panel* from the top menu bar and then select the *Menus* option. |
| 3\. | On the **Menu Bar Definition** dialog, click the *Menu Colors* button. When no colors have been defined, this button displays as shown below:<br>![](https://manual.pvxplus.com/migration-assets/882654488ae0793a40db4fbd478e625ef1896dd25e17a8ff36a48525e61545b2.png) |
| 4\. | The **Define Menu Colors** dialog displays. Initially, all of the inputs show the default values:<br>![](https://manual.pvxplus.com/migration-assets/ba86cfc3575d6404ed5afaf4a452bca9adb3c498066c89b6d8a64669a4b11666.jpg) |
| 5\. | Under the **Menu Colors** section, change each of the following options by clicking the Color Selections (*paint palette*) button, which displays the **Color Selections** window:<br>• For *Text*, select *White* and then click *OK*.  <br> • For *Background*, select *Dark Green* and then click *OK*.  <br> • For *Edge*, select *Light Green* and then click *OK*. |
| 6\. | The **Menu Colors** selections looks like this:<br>![](https://manual.pvxplus.com/migration-assets/6301dd7eaa23011901eac121e9b4c9f8f7018e456dfed67da7fbe2547e024049.png) |
| 7\. | Click *OK* to save and exit the **Define Menu Colors** dialog. |
| 8\. | You are returned to the **Menu Bar Definition** dialog. The *Menu Colors* button changes color and displays a green check mark to indicate that colors have been defined.<br>![](https://manual.pvxplus.com/migration-assets/ff7b30ccea7cfb8b80234fc10279fa97d8072e909ad49b37bba077238c5bbe09.png) |
| 9\. | Click the *Save* toolbar button and then close this dialog. You are returned to the Panel Designer. |
| 10\. | To see the result, test the panel. Notice that the menu colors are applied to the sub-menus only.<br>![](https://manual.pvxplus.com/migration-assets/65b533964280c86af966cb6721d366585bc312aa2680a5e03ce021e340b8daaf.png) |
| 11\. | Edit the menu definition so that the menu colors are applied to the top menu also.<br>Invoke the **Menu Bar Definition** dialog again and click the *Menu Colors* button.<br>Click the drop down arrow on the *Apply Menu Colors to Top Menu* option and then select *Yes*.<br>![](https://manual.pvxplus.com/migration-assets/d7c0e096df77e21766dfa5183612a05cef187308940ef746f74907b11ce057e5.png) |
| 12\. | Click *OK* to save and exit the **Define Menu Colors** dialog. |
| 13\. | You are returned to the **Menu Bar Definition** dialog. |
| 14\. | Click the *Save* toolbar button and then close this dialog. You are returned to the Panel Designer. |
| 15\. | To see the result, test the panel. Notice that the menu colors are applied to the top menu also.<br>![](https://manual.pvxplus.com/migration-assets/5a3ffd49237f827100bc558aec763295f93571246fd6c0af4a2c95761e32f693.png) |
| 16\. | This menu can be enhanced even further by adding a hover background color and a hover text color. This can be done by defining a Visual Class (or Theme) for the Menu_Bar control type to set the *Hover Background Color* and *Hover Text Color* properties.<br>Invoke the **Visual Classes Maintenance** utility. From the IDE Main Launcher, expand the *Graphical Application Builder (NOMADS)* category, and then expand the *Setup* category. Select *Visual Classes*.<br>Note:  <br>Visual Classes and Themes may also be defined for Popup_Menu control types. Their properties are identical to Menu_Bar control types, except for the Use Color on Top Level property. |
| 17\. | If the Visual Classes file does not exist, a message will display to ask if you want to create it. If this happens, click *Yes*. |
| 18\. | The **Visual Classes Maintenance** utility is displayed.<br>![](https://manual.pvxplus.com/migration-assets/8b9946c010c9ef28385bcd70a2fb1af21def74acc2c04ae669758957ee1ad6e4.png) |
| 19\. | Enter a unique Visual *Class Name*. For this example, enter MENU. |
| 20\. | For *Control Type*, select *Menu_Bar* from the drop down list, and then enter a *Description* (optional). The grid lists the Menu Bar properties.<br>![](https://manual.pvxplus.com/migration-assets/eede335b03eba3a45e1d59eef9cf851387fb081ed397a1194c50efd5d31bf70f.png) |
| 21\. | To set the *Use Color on Top Level* property, click the drop down arrow in the *Value* column, and then choose a value. For this example, select *Yes*. |
| 22\. | To set each of the color properties as shown below, click the three-dotted button in the *Value* column. The **Color Selections** window displays. |
| 23\. | Select the color and then click *OK*. The selected color displays in the *Value* column. A small triangle shows a sample of this color in the upper left corner of the cell.<br>![](https://manual.pvxplus.com/migration-assets/ef248aba1f54e7274661b945751136dd7335570f39a883dcbefb57b099e6f6a7.jpg) |
| 24\. | When done, click the *Write* button, and then the *Exit* button. |
| 25\. | In the NOMADS Panel Designer, load the same panel that contains the menu definition. |
| 26\. | Invoke the **Menu Bar Definition** dialog, and click the *Menu Colors* button. |
| 27\. | Under **Visual Class**, click the drop down arrow in the second input. Select the Visual Class you just created (MENU).<br>![](https://manual.pvxplus.com/migration-assets/3c3c4cbae1ffc86218b7003771a90d6b188f4dd8fec165a39290087723a9a466.png) |
| 28\. | Click *OK* to save and exit the **Define Menu Colors** dialog. |
| 29\. | You are returned to the **Menu Bar Definition** dialog. |
| 30\. | Click the *Save* toolbar button and then close this dialog. You are returned to the Panel Designer. |
| 31\. | To see the result, test the panel. Notice the following:<br>• The selected colors for *Hover Background Color* and *Hover Text Color* are applied.<br>• The Blue colors selected for the Visual Class properties, *Menu Background Color* and *Menu Left Edge Color*, override the Green colors defined for the menu in **[Step 5](https://manual.pvxplus.com/how-to/how-to-add-clr-to-menu-defs#Mark5)**.<br>![](https://manual.pvxplus.com/migration-assets/f2094ec20f75490c0aa63a7339b1c1cc9ecaebf3f5cb0a5149fd7164504702e0.png) |

***Assigning Colors to Individual Menu Items***

Using **Menu Bar Definition**, colors can also be assigned to individual menu items.

For this example, the sample menu above will be used to assign different colors to Saturday and Sunday in the top menu bar.

|  |  |
| --- | --- |
| 1\. | Invoke the **Menu Bar Definition** dialog for this menu. Double click on the &Saturday group in the list box on the right.<br>![](https://manual.pvxplus.com/migration-assets/ebf4660e0a3a094b069db9d9828c7c091afed72be1716ae28af85a395969c2a2.png) |
| 2\. | The **Menu Item/Group Definition** dialog displays. Click the **Attributes** tab.<br>Under the **Item Colors** section, the *Background* and/or *Text* colors for an individual menu item can be assigned.<br>![](https://manual.pvxplus.com/migration-assets/e7132e947b3bf183a42b45c46d2c4a06a16b7c56fa76ec8a6a7b5ea3ac0da25a.png) |
| 3\. | Click the *Background* drop down arrow and select *Specify Color*. |
| 4\. | Click the Color Selections (*paint palette*) button to display the **Color Selections** window. Select *Light Yellow* and then click *OK*. |
| 5\. | Click the *Text* drop down arrow and select *Specify Color*. |
| 6\. | Click the Color Selections (*paint palette*) button to display the **Color Selections** window. Select *Black* and then click *OK*. |
| 7\. | The colors for the &Saturday group are now defined. Click *OK* to save.<br>![](https://manual.pvxplus.com/migration-assets/9ad8dd878b3fee71c10973b34c11bdc072a6879216eea7a9df765ee0375fe13e.png) |
| 8\. | You are returned to the **Menu Bar Definition** dialog. Double click on the S&unday group. |
| 9\. | The **Menu Item/Group Definition** dialog displays. Click the **Attributes** tab. |
| 10\. | Specify the same *Background* and *Text* colors for the S&unday group as you did for the &Saturday group. |
| 11\. | When done, click *OK* to save. You are returned to the **Menu Bar Definition** dialog. |
| 12\. | Next, assign *Background* and *Text* colors for each item under the &Saturday group. Click on the &Saturday group in the **Groups** tree view control on the left. The contents of this group are listed on the right. |
| 13\. | Double click on the first item under the &Saturday group. |
| 14\. | The **Menu Item/Group Definition** dialog displays. Click the **Attributes** tab. |
| 15\. | Assign the *Background* and *Text* colors for this item. Items on a menu can be assigned unique colors, if desired.<br>For this example, the same colors as before will be used: Light Yellow for the *Background* color, and Black for the *Text* color. |
| 16\. | Double click on the second item under the &Saturday group. Specify the same *Background* and *Text* colors for this item. |
| 17\. | When you are done assigning colors for each item, click the *Save* toolbar button and then close this dialog. You are returned to the Panel Designer. |
| 18\. | To see the result, test the panel. Notice the assigned colors for Saturday and Sunday.<br>![](https://manual.pvxplus.com/migration-assets/f79c7a9c2d1b275eb4fac5d814e61b6505d4e647d6e81bc6b7eec44bde96ddaf.png) |

Note:  
The above procedures also work when defining a Popup Menu. The only difference is that the Apply Menu Colors to Top Menu option is not available for a Popup Menu.

## See Also

**[%NOMADS Properties](https://manual.pvxplus.com/nomads-graphical-application/appendix/nomads-variables/overview#properties)**  
**[NOMADS Environment Maintenance](https://manual.pvxplus.com/nomads-graphical-application/maintain-nomads-environment)**  
**[Themes](https://manual.pvxplus.com/nomads-graphical-application/system-maintenance-tools/system-options/themes)**  
**[Visual Classes](https://manual.pvxplus.com/nomads-graphical-application/system-maintenance-tools/system-options/visual-classes)**  
**[Menu_Bar Properties](https://manual.pvxplus.com/nomads-graphical-application/system-maintenance-tools/system-options/themes-vc-menu)**  
**[Popup_Menu Properties](https://manual.pvxplus.com/nomads-graphical-application/system-maintenance-tools/system-options/themes-vc-popup)**  
**[Menu Bar Definition](https://manual.pvxplus.com/nomads-graphical-application/creating-panel-controls/menu-bar/menu-bar-definition)**  
**[Creating a Menu Item and Group](https://manual.pvxplus.com/nomads-graphical-application/creating-panel-controls/menu-bar/creating-a-menu-item-and-group)**
