There are a number of predefined events that get called at various times. These events can have sequence script to perform special actions. The script runs in the context of the component (meaning, for example, that you can access the properties of the component without putting component.myname. in front). To edit the events, use the Event/Function docking window or select them in the component's properties window. If the Event docking window isn't visible, or tabbed along the right side, select View-Event/Function from the main menu.
While some components will have additional events, all components have the following Events:
OnContextMenu: called when the user right clicks on the component. The parameter loc is passed in which contains the x/y coordinate where the click occurred relative to the top left corner of the component. Loc[0][0] contains x, loc[0][1] contains y.
OnLButtonDblClk: called when the user double clicks on the component. Like OnContextMenu, loc is passed in.
OnLButtonDown: called when the user clicks down on the mouse on the component. Like OnContextMenu, loc is passed in. If you return(1) from your function, then DAQFactory will not process this event for any other components (such as ones underneath this component).
OnLButtonUp: called when the user releases the mouse on the component. Like OnContextMenu, loc is passed in. If you return(1) from your function, then DAQFactory will not process this event for any other components (such as ones underneath this component).
OnLoad: called when the component is created or loaded from disk. This is the best place to put local declarations and CreateProperty() function calls.
OnMessage: this function is called when a message that this component is listening for is received. To listen for a particular message, use the AddListener() function described in the last section. When a known message is received, this event passes in strMessage containing the message name, as well as Param1 and Param2, containing the parameters passed when the message was sent. To actually send a message use the SendMessage() function. This function has the prototype: SendMessage(Message, Param1, Param2). The message will be sent to all listening components. This function is of global scope.
OnMouseMove: called when the user moves the mouse pointer over the component. Like OnContextMenu, loc is passed in.
Note: If you use the OnMouseMove event, make sure it is quite fast, otherwise the mouse will become sluggish when you move it over the component. Really, all the event code must be fast as it runs in the primary thread of the application and would cause DAQFactory to appear sluggish.
OnPaint: called before the component is painted to the screen. This is a good place to adjust standard properties like background color or text before the component is drawn. There is no facility to draw from this event. If you want to do scripted drawing, use the Canvas component.
Note: MouseMove and Paint events can occur very rapidly and any error can cause a continuous stream of repeated errors in the Command / Alert Window. For this reason there is the System.ShowPaintMouseErrors variable. If this variable is 0, the default, then any script errors in MouseMove or Paint component events are not sent to the command / alert window. To see these errors, set this variable to 1.
OnLinked: this is an unusual event and only used when the component is linked to the Linked Component. It is especially unusual because the event is called by the Linked Component, not the component that has been linked and contains the event. This event is usually used to create properties in the Linked Component. Please see section 7.18.2.11 for more information on the Linked Component and this event.