How Do I Raise Events Defined in the Host Application from a Component? (Magic xpa 4.x)
Sometimes it is useful to be able to raise an event in a component that can be handled in the host component. For instance, it is common for packaged routines to raise an event if an error happened. In our example here, we raise an event in the component called “LogCall”, which passes parameters about the call, so the host application can store the information if needed.
-
Create your Raise Event operation in the location you want it. The Event dialog will appear.
-
Go to the Event type field. Select Public Event.
-
Go to the Event field. Zoom, which will bring you to the Expression rules. Type in the name of the event, spelled exactly as it will be in the host event, in single quotes.
This will cause the component to raise an event that can be handled by the host component. Now you need to set up the host component to capture the event.
-
Create an event in the Main Program, with the exactly the same Public Name as the event you raised in the component.
-
Check the Expose box.
Now, you can create handlers to handle the event as needed.