Customizing the ATEasy Test Executive to Add Context Menus to Test Nodes

Knowledge Base Article # Q200257

Read Prior Article Read Next Article
Summary This article takes a closer look into the Test Executive code which creates test nodes dynamically and improves upon the design by adding user-defined context menus to add functionality.
Login to rate article
In the Test Executive ATEasy driver, the formTestExec creates the test tree view and the test nodes dynamically by reading data from the Program module (or Profile).  The precise location of the node creation is with the driver procedure FillProgramTree().  To add a context menu to allow right-click operation of a node, we will need to create an AMenu of type Popup at design-time and display it at run-time.  In addition, each item in the AMenu will need to have an associated event procedure attached, which can be accomplished using a generic function call and the currently selected node.

ATEasy Test Executive Tree View Pane

This project involves modifying the Test Executive driver which may be shared between multiple projects.  Because of this, it may be prudent to make a backup copy of the TestExec.drv before proceeding.

Create a new popup menu at design-time

TestExec.drv includes several forms including the main Test Executive GUI class named formTestExec.  This form already includes a populated menu bar, mnuTestExec, but we will be adding our own secondary menu which will be invisible until it is needed.  To create the new pop-up menu:

  • Click on the AMenu Control icon from the Controls Toolbox.  Click and drag anywhere within your formTestExec to add a new menu to the form.  Rename this menu of Type bar to mnuContext.
  • Click on the <New Item> entry and open the properties editor.  By default, this entry is type Bar which means it will appear as a bar near the top of the form.  Change the type to Popup, which means it will contain other menu items.
  • In the Properties window change the Name of the selected object to mnuPopup, change the Caption to My Popup, and uncheck the Visible property.  This will allow us to hide the menu when it is not in use.
  • Select the <New Item> menu that is contained within our mnuPopup and open the properties editor.  By default, this menu is type Item which means it is a menu item intended to execute some function.
  • In the Properties window change the Name of the selected object to mnuHighlight, and change the Caption to Highlight Node.

Next, add the code that will perform the highlight operation:
  • Double-click the Highlight Node menu item.  This should take open mnuHighlight’s OnClick() function.
  • Add the following code:

The variable f_node does not exist yet, so create the form variable as follows:
f_node : MSComctlLib.Node

Display the popup menu when a user right-clicks a node

First, we will create an event to fire when the nodes are right-clicked.  Since the Test Executive already makes use of a custom mouse-click event, we will add our code to that event.  Go to the formTestExec’s procedures list and select OnTreeViewMouseUp().  This event fires each time a mouse button is released over the tree view.  Add the following lines to the beginning of the procedure:
! If the user executed a right-click
If Button=aMouseButtonRight
    ! Add the toolbar offset to the y-location of the popup
    ! Display the context menu
    Form.PopupMenu(mnuPopup, aformPopupMenuRightButton, x, y)

Leave the rest of the code in OnTreeViewMouseUp() alone.
Run the project and try right-clicking the nodes.

ATEasy Test Executive with Context Menu

Download the modified TestExec here.
Article Date 9/3/2015 , 9/8/2021
Keywords ATEasy, Test Executive, TestExec.drv, Customizing

Login to rate article

Read Prior Article Read Next Article