JavaScript Editor js editor     Web development 



Main Page

Though some events occur as single events, a user action often triggers multiple events. Some of these events occur independently; however, some event sequences are fixed, for example, the event sequence that occurs when a form is created or destroyed.

When a sequence of events is triggered for a control, the entire sequence of events is associated with the control. For example, suppose you click the left mouse button on a command button and the drag the mouse pointer away from the command button. The command button's MouseMove event continues to occur even though the mouse pointer moves over the form. If you release the left mouse button over the form instead of over the command button, the MouseUp event that occurs is associated with the command button instead of the form.

The following table shows the general sequence of Visual FoxPro events, assuming that the data environment's AutoOpenTables property is set to True (.T.). Other events can occur based on user interaction and system response.

Visual FoxPro Event Sequence

Object Event that occurs

Data environment

BeforeOpenTables

Form set

Load

Form

Load

Data environment cursor(s)

Init

Data environment

Init

Objects 1

Init

Form

Init

Form set

Init

Form set

Activate

Form

Activate

Object1 2

When

Form

GotFocus

Object1

GotFocus

Object1

Message

Object1

ValidВ 3

Object1

LostFocus

Object2 3

When

Object2

GotFocus

Object2

Message

Object2

ValidВ 4

Object2

LostFocus

Form

QueryUnload

Form

Destroy

Object 5

Destroy

Form

Unload

Form set

Unload

Data environment

AfterCloseTables

Data environment

Destroy

Data environment cursor(s)

Destroy

1. For each object, from innermost object to outermost container 2. First object in the tab order 3. Next object to get focus 4. As the object loses focus 5.For each object, from outermost container to innermost object

Event Sequence Example

The following example uses a form to illustrate the order in which events occur in response to user interaction.

FoxProFormEvenSequence screenshot

In this example, the user performs the following actions:

  1. Runs the form.

  2. Types text in the Text1 text box.

  3. Selects the text and copies it to the Clipboard.

  4. Moves to the Text2 text box by pressing the TAB key.

  5. Pastes the text into Text2.

  6. Closes the form by clicking the Command2 command button.

These actions trigger system events for each object. The following tables list the events that occur in response to each user action.

Note:
In this example, the Paint event has been removed from the tables because this event occurs frequently and makes it difficult to see the sequences of the other events.

Action 1

The user runs the form by typing the following command in the Command window:

В Copy Code
DO FORM form1 NAME frmObject

Visual FoxPro loads the form, initializes each object, and then initializes the form. The form is activated and the first text box receives input focus.

Object Event

DataEnvironment

BeforeOpenTables

Form1

Load

DataEnvironment

Init

Text1

Init

Text2

Init

Command1

Init

Command2

Init

Form1

Init

Form1

Activate

Form1

GotFocus

Text1

When

Text1

GotFocus

Action 2

The user types the text "Test" in the text box, Text1. Each keystroke generates two events.

Note:
The KeyPress event receives two parameters: a number representing the pressed key and the state of the SHIFT, ALT, and CTRL keys.

Object Event Parameters

Text1

KeyPress

(84 for "T", 1)

Text1

InteractiveChange

В 

Text1

KeyPress

(101 for "e", 0)

Text1

InteractiveChange

В 

Text1

KeyPress

(115 for "s", 0)

Text1

InteractiveChange

В 

Text1

KeyPress

(116 for "t",0)

Text1

InteractiveChange

В 

Action 3

The user selects the text in the text box, Text1, by double-clicking the text and copies the text to the Clipboard by pressing CTRL+C. Mouse events and a Click event accompany the DblClick event.

Note:
The MouseMove, MouseDown, and MouseUp events receive four parameters: a number indicating the pressed button, the state of the SHIFT key, and (X, Y) coordinates. The X and Y coordinates are relative to the form and reflect the form's scale mode, for example, pixels. Though only one MouseMove event is listed for each control, in actuality, this event can occur half a dozen times or more.

Object Event Parameters

Form1

MouseMove

(0, 0, 100, 35)

Text1

MouseMove

(0, 0, 44, 22)

Text1

MouseDown

(1, 0, 44, 22)

Text1

MouseUp

(1, 0, 44, 22)

Text1

Click

В 

Text1

MouseDown

(1, 0, 44, 22)

Text1

MouseUp

(1, 0, 44, 22)

Text1

DblClick

В 

Action 4

The user moves to the text box, Text2, by pressing the TAB key.

Object Event Parameters

Text1

KeyPress

(9, 0)

Text1

Valid

В 

Text1

LostFocus

В 

Text2

When

В 

Text2

GotFocus

В 

Action 5

The user pastes the text into the text box, Text2, by pressing CTRL+V.

Object Event

Text2

InteractiveChange

Action 6

The user clicks the command button, Command2, to close the form.

Object Event В 

Form1

MouseMove

В 

Command2

MouseMove

В 

Text2

Valid

В 

Command2

When

В 

Text2

LostFocus

В 

Command2

GotFocus

В 

Command2

MouseDown

(1, 0, 143, 128)

Command2

MouseUp

(1, 0, 143, 128)

Command2

Click

В 

Command2

Valid

В 

Command2

When

В 

When the form closes and objects are released, additional events take place in the opposite order of the events listed for Action 1.

Object Event

Form1

Destroy

Command2

Destroy

Command1

Destroy

Text2

Destroy

Text1

Destroy

Form1

Unload

DataEnvironment

AfterCloseTables

DataEnvironment

Destroy

See Also



JavaScript Editor js editor     Web development