Register to Events      


Registers the toolkit support set to listen for events on the elements contained in the custom control.


function <register to events>(elem)




Unused. Preserved for backward compatibility.

Return Value

true on success, otherwise false.

  • UFT One asks the toolkit which events the toolkit will use to record test steps on this control by calling the <register to events> function specified in the EventListening elements in the toolkit configuration file for the class to which this control belongs.
  • You can use this method if, in your toolkit, the root element of all custom controls is an element that UFT One learns. With this type of function, there is no way to specify that a different element than the one being learned is the root element.
  • Define the name of the function in a Control\Record\EventListening element in the toolkit configuration file.
  • The functions specified in the EventListening element are passed one parameter, a reference to the element being processed. This parameter is preserved for backward compatibility. Best practice is to use the _elem token instead. When this function is called, the _elem token represents the root element of the control as set by the identification functions or the toolkit configuration file. Therefore, the structure of the _elem token is known, whereas it may difficult to determine exactly what the input element argument refers to.
  • A register to events function calls _util.RegisterForEvent one or more times. The arguments that _util.RegisterForEvent receives are the element on which to listen to events, the event to which to register, the name of the function to be called when the event occurs, and an optional parameter to be passed to the event handler. If no parameter is specified, the event handler is passed null.

In this example, the toolkit support set registers for onclick events for each panel header in a StackPanel.

From the toolkit configuration file:



        <EventListening use_default_event_handling_for_children="false"


            type="javascript" function="ConnectToEvents"/>



The event handlers will be passed a reference to the stacked panel on which the event occurred.

function ConnectToEvents(elem)


    var stackPanels = getStackPanelItems(_elem);

    // Listen to click events on each of the panel headers in the StackPanel.

    for (var i = 0; i < stackPanels.length; i++)


        _util.RegisterForEvent(stackPanels[i], "onclick",

            "OnPanelSelect", stackPanels[i]);


    return true;