Individual annotations when using multi-select

25 views
Skip to first unread message

Randy Haid

unread,
Mar 23, 2021, 1:50:25 PM3/23/21
to PDFTron SDK
Hello!

I'm using v. 8.1.2 of the iOS SDK and trying to figure out how to "see" which annotations are included when the user uses the multi-select tool.

I'm overriding a function:

 toolManager(_ toolManager: PTToolManager, shouldShowMenu menuController: UIMenuController, forAnnotation annotation: PTAnnot?, onPageNumber pageNumber: UInt) -> Bool

So that I can inject my own menu item when the menu pops up.  My menu item triggers on action on whatever annotation triggers that call.  This works perfect!  No issues at all.

But if the user uses the multi-select tool and grabs more than one annotation, that function only gets called once, and it kinda looks like the SDK is creating some sort of "temporary" annotation to represent what the user selected.

Is there any kind of "for annotation in selectedAnnotations" that I can iterate over?  Or even some way of recognizing that the user triggered that function via the multiselect? (i.e. as a last resort, I could maybe just hide my menu item in that case)

Thanks!
Randy

James

unread,
Mar 24, 2021, 3:03:13 PM3/24/21
to PDFTron SDK
Hello Randy,

When multiple annotations are selected, that callback passes the first annotation only. You can get the complete list of annotations by checking the currently active tool:

((documentController.toolManager.tool) as? PTAnnotEditTool)?.selectedAnnotations

Please let me know if this helps.

James

Randy Haid

unread,
Mar 24, 2021, 3:38:30 PM3/24/21
to PDFTron SDK
This works like a champ!  Thanks James! :)

James

unread,
Mar 24, 2021, 5:15:27 PM3/24/21
to PDFTron SDK
Great, thanks for letting us know.
Reply all
Reply to author
Forward
0 new messages