When the mouse is pressed, the OnMouseDown/ OnMouseUp event of the pressed part is called. At the same time, the OnMouseDown/ OnMouseUp event is called on the root. The information passed to the root event is object (the part on which the mouse was pressed) as the first argument. Subsequent arguments are the same as for the OnMouseDown/ OnMouseUp events of a normal part. The object is also passed as the first argument to the following events.
OnMouseIn / OnMouseMove / OnMouseOut / OnMouseDblClick
Root events are useful when you want to perform common processing on all screens.
For example, if you want to record all button presses in the history, it would be tedious to write a script for the MouseUp event of each component, so it is convenient to put the process in the root. Since an object is passed as the first argument, you can use the ClassId property to determine which type of component the button was pressed on.
Example) If you want to keep history only with Button control
event OnMouseUp(object, button)
{
if (object.ClassId == "Button"){
// To log to a text file, use the
pasted into HiddenForm // It is convenient to use Text dump control
::OpenMsg(" button was pressed.");
}
}
|