add_run(function(sender, e)) run.add(function(sender, e)) remove_run(function(sender, e)) run.remove(function(sender, e))
When an object is being run, the automation object will hook the object run designer's AnnRunDesigner.Run to this event. Therefore, instead of hooking and unhooking to the various designers run events, you can simply subscribe to this event once.
This example will show how to track when an object is run.
Start with the AnnAutomationManager example, remove all the code inside the example function (search for the // TODO: add example code here comment) and insert the following code:
Draw a couple of objects and then click the example button. Now you switch into run mode and whenever you click on an object, a message will show.
example: function SiteLibrary_DefaultPage$example() { // Switch to run mode this._automation.get_manager().set_userMode(lt.Annotations.Core.AnnUserMode.run); // Hook to the automation's Run event this._automation.add_run(function(sender, e) { // e is of type AnnRunDesignerEventArgs if(e.get_operationStatus() == lt.Annotations.Core.AnnDesignerOperationStatus.start) { // Get the object being run alert("In run mode, you clicked an object of id " + e.get_object().get_id()); } }); },
Parameter | Type | Description |
---|---|---|
sender | 'var' | The source of the event. |
e | AnnRunDesignerEventArgs | The event data. |