>The new BINDEVENT() function has a
nFlags parameter that defaults to 0, that value specifying "
Call delegate code before event code.".
>Now a
nFlags value of 2 is available and in this case it is used to specify "
Do not trigger event (call delegate code) when a simple method call occurs.".
>
>Now the RAISEEVENT() "Remarks" starts with the following:
>
Visual FoxPro does not automatically raise 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:oForm.GetMyData(cData)
Instead, to raise an event for a custom method, you need to make the following call:>RAISEEVENT( oForm, "GetMyData", cData )
You can also change this behavior by using BINDEVENT( ) with nFlags set to 2 or 3.>
>This looks contradictory to me in that the
default of 0 in BINDEVENTS() should automatically call the custom method, should it not?
It's not contradictory, just obfuscated.
That documentation is not wrong, it contains all the correct facts.
Just not in a logical order :)
The oForm.GetMyData(cData) will not raise an event, that is perfectly true.
What they forgot to say, I think, is that if you call BINDEVENT() with the defaults it should still work in that case.
The only time that simple method calls do NOT work is if you specifically tell VFP not to handle it, with the second bit (values 2 or 3).
So the example code has a bit missing:
BINDEVENT( oForm, "GetMyData", MyObject, "Delegate", 2 )
oForm.GetMyData( cData )
RAISEEVENT( oForm, "GetMyData", cData )
So raise it as a DOC bug by all means !