Visual Basic
In Visual Basic, the event handler is created as a listener class with the following code. Note that Print is a reserved method name in Visual Basic, so the Application.Print method is not available; the VB Debug.Print method is used instead.
Option Explicit
Implements IDOMEventListener
Private Sub IDOMEventListener_handleEvent _
(ByVal evt As IDOMEvent)
Dim node As IDOMNode3
Set node = evt.target
Dim context As String
context = ""
While Not node Is Nothing
If node.nodeType = NODE_ELEMENT Then
context = "(" & node.nodeName & context
End If
Set node = node.parentNode
Wend
Debug.Print context
evt.stopPropagation
End Sub
Then a Visual Basic form must be created with this code included to register the event listener:
Option Explicit
Dim myListener As IDOMEventListener
Dim app As Epic.Application
Dim activeDoc As DOMDocument
Dim target As IDOMEventTarget
Private Sub Form_Load()
Set myListener = New Listener
Set app = New Epic.Application
Set activeDoc = app.ActiveDocument
Set target = activeDoc
target.addEventListener "click", myListener, False
End Sub