JavaScript Editor js editor     Web development 



Main Page

Events occur automatically when the system or application user performs a specific action. Events associated with an object occur when a user interacts with the object in any way, such as tabbing to it, clicking it, or moving the mouse pointer over it. For example, the CommandButton class contains a Click event that is triggered when the user clicks the command button.

You can add code to the event procedure of an object so that when the event occurs for the object, the code executes automatically. For example, you can add code to the Click event so that when the user clicks the command button, the code executes automatically to perform an action, such as opening a form. System events can also execute code in events as in the case of the Timer event in a Timer control.

The following table contains a list of the core set of Visual FoxPro events, which apply to most controls.

Core Events in Visual FoxPro

Event Event occurs when

Init

An object is created.

Destroy

An object is released from memory.

Click

The user clicks the object using the primary mouse button.

DblClick

The user double-clicks the object using the primary mouse button.

RightClick

The user clicks the object using the secondary mouse button.

GotFocus

The object receives the focus through user action such as tabbing or clicking or by changing the focus in code using the SetFocus Method. For more information, see SetFocus Method.

LostFocus

The object loses the focus through user action such as tabbing to or clicking another object or by changing the focus in code using the SetFocus method.

KeyPress

The user presses and releases a key.

MouseDown

The user presses the mouse button while the mouse pointer is over the object.

MouseMove

The user moves the mouse pointer over the object.

MouseUp

The user releases the mouse button while the mouse pointer is over the object.

Triggering Events Programmatically

Most events occur automatically when the system or user performs an action. However, you can generate the following events programmatically using certain Visual FoxPro commands:

  • Use the MOUSE command to generate the Click, DblClick, MouseMove, and DragDrop events.

  • Use the ERROR command to generate the Error event.

  • Use the KEYBOARD command to generate the KeyPress event.

For more information, see MOUSE Command, ERROR Command, and KEYBOARD Command.

Though you cannot trigger most events programmatically, you can call the procedure associated with the event, which executes the code in the event but does not trigger the event itself. For example, the following line calls the Activate event procedure for the form frmPhoneLog and executes the code in the event; however, it does not activate the form itself:

В Copy Code
frmPhoneLog.Activate

If you want to activate the form, use the form's Show method:

В Copy Code
frmPhoneLog.Show

Calling the Show method displays and activates the form, which also executes the code in the Activate event.

See Also



JavaScript Editor js editor     Web development