JavaScript Editor js editor     Web development 



Main Page

You can use RAISEEVENT(В ) to raise, or trigger, an event from a custom method. Though RAISEEVENT(В ) applies primarily to custom methods, you can use it for raising native events and methods.

RAISEEVENT( oEventSource, cEvent [, eParm1...] )

Parameters

oEventSourceВ В В 


Specifies the event source, which must be a valid Visual FoxPro object.
cEvent


Specifies the name of the event, method, or property you want to raise.
eParm1...


Specifies one or more parameters to pass if the method has parameters.

Return Value

Logical data type. RAISEEVENT(В ) always returns True (.T.).

Remarks

Visual FoxPro automatically raises events for custom methods that are bound to objects using BINDEVENT(В ) if the methods are called directly. For example, the following code does not raise an event:

В Copy Code
oForm.GetMyData(cData)

Instead, to raise an event for a custom method, you need to make the following call:

В Copy Code
RAISEEVENT( oForm, "GetMyData", cData )

You can also change this behavior by using BINDEVENT(В ) with nFlags set to 2 or 3.

The event you wish to raise must be marked Public, not Hidden or Protected.

If you use RAISEEVENT(В ) on a property, Visual FoxPro sets the property to itself. The following example sets the Caption property for _SCREEN to the current value for Caption:

В Copy Code
RAISEEVENT( _SCREEN, "Caption" )

Raising an event fails if you bind to an event, for example, using BINDEVENT(В ), that has parameters that are passed by reference.

Visual FoxPro disregards recursive RAISEEVENT(В )calls to an event from within the same raised event.

Example

Activating a form or using Form1.Show triggers the Activate event for the form. However, calling the Activate event directly using a call such as Form1.Activate does not trigger the Activate event. The following example shows how you can use RAISEEVENT(В ) to trigger the Activate event:

В Copy Code
RAISEEVENT( Form1, "Activate" )

See Also



JavaScript Editor js editor     Web development