JavaScript Editor js editor     Web development 

Main Page

When you add code to events, remember the following considerations:

The following sections contain more information about the last three considerations.

Events of Objects in Containers

Each object, even those in containers, receives its events independently. For example, suppose a form contains a command button. When the user clicks the command button, only the Click event for the command button is triggered, not the form's Click event. Therefore, if code exists for a form's Click event but no code exists for the command button's Click event, nothing happens when the user clicks the button.

This consideration also applies to grid controls. A grid contains columns, which contain headers and controls. When an event occurs for an inner object, only the object associated with event recognizes the event. The higher-level container does not recognize the event.

An exception to this rule exists. If event code exists for an option button group or a command button group, but no event code exists for the event of a particular option or button in the group, the group's event code is executed when the event for the particular option or button occurs.

Events of Controls from User-Defined Classes

When an event occurs for a control based on a user-defined class, Visual FoxPro checks the control for event code. If code exists in the control's event procedure, Visual FoxPro executes it. However, if no code exists in the control's event procedure, Visual FoxPro searches the next level up in the control's class hierarchy for code associated with that event. If Visual FoxPro finds code for the event, it executes that code and does not continue searching further up the hierarchy.

Event Sequence Considerations

When determining where to add event code, remember the following considerations:

  • The Init event of a form occurs after all Init events for controls on the form occur. Therefore, you can include code in the form's Init event to manipulate any of the controls on the form before the form displays.

  • If you want to execute code when the value of a list box, combo box, or check box changes, add the code to the control's InteractiveChange event instead of the Click event. The Click event might not occur or might be called even if the value does not change.

  • When you drag a control, other mouse events are suspended. For example, the MouseUp and MouseMove events do not occur during a drag operation.

  • The Valid and When events return a value with True (.T.) as the default. If code returns False (.F.) or 0 in the When event, the control cannot receive focus. If code returns False (.F.) or 0 in the Valid event, focus cannot leave the control.

See Also

JavaScript Editor js editor     Web development