EventSinkService.NodeInserted only works with newly opened form, not with saved document, ...


https://www.nevron.com/Forum/Topic9226.aspx
Print Topic | Close Window

By Chris Kiekens - 9 Years Ago

I have thefollowing problem:

I need toopen a document and have the NodeInserted event enabledto do something when a node gets inserted.

I use thishandler, manually set through a Button:

AddHandler Me.NDrawingDocument1.EventSinkService.NodeInserted, AddressOfEventSinkService_NodeInserted

The event works fine if I start the form, click on the button and then drawan object.

The event does NOT work:

- if I open a new document through the white page button on the nevrontoolbar and click the button that adds the handler

- if I open a saved document through nevron toolbar and click the buttonthat adds the handler

- if I read in a BLOB and click the button that adds the handler

No error, just the event is not fired by the document. What am I doing wrong?

By Nevron Support - 9 Years Ago

Hi,

When a document is loaded, or a new document is created, the diagram replaces the drawing view document. That is why you stop to receive events, because you remain connected to the old document that is not used any more. You need to reinstall your event handlers in these case.

By Chris Kiekens - 9 Years Ago
Hi,

I did reinstall the eventhandler with this code every time I started the program or opened a document:
AddHandler NDrawingDocument1.EventSinkService.NodeInserted, AddressOf EventSinkService_NodeInserted
And it does work, but only the first time when opening the form.

I had to change it to work all the time:
AddHandler NDrawingView1.document.EventSinkService.NodeInserted, AddressOf EventSinkService_NodeInserted
I hope this helps those with the same problem.

Thanks anyway!