ToolManager events not being raised?

Hi,

I am working on a Xamarin Forms app with PDFTron integration.

I seem to be experiencing the situation where the app works as expected in the iOS simulator, but on a physical device, tool manager events don’t appear to be raised

For example, my event registration code looks like this. I am using PTDocumentViewController as the main viewer component (as opposed to using PDFViewCtrl directly).

PTToolManager toolManager = _ptDocViewController.ToolManager;
toolManager.AnnotationAdded += OnToolManagerAnnotationsAdded;
toolManager.AnnotationRemoved += OnToolManagerAnnotationsRemoved;
toolManager.AnnotationModified += OnToolManagerAnnotationsModified;
toolManager.ShouldShowMenu = new ShouldShowMenu(OnShouldShowMenu);

On a simulator, the handlers are called as I would expect, but not an a physical device.

It could be that I am doing something wrong, but has anyone else seen this difference? Or had trouble receiving events from the tool manager?

-John

I think I can sort of answer my own question:

I was able to get reliable notifications by subclassing PTDocumentViewManager and overriding AnnotationAdded, AnnotationRemoved, etc, instead of subscribing to ptDocViewController.ToolManager events.

I’m still not sure why there was a discrepancy between a physical device and the simulator though.

Hello John,

Thank you for raising this issue.

The recommended approach to receiving tool manager events is to subclass the PTDocumentViewController class and override the methods, as you have already found. When you register event handlers for tool manager events, this disconnects the internal connection between the PTToolManager and PTDocumentViewController, which is set as the tool manager’s delegate. Breaking this internal connection can cause strange issues to occur.