I’m in the process of converting a PDF editor from MacOSLib to MBS, and some seemingly simple actions don’t translate easily. For example, how does on display a selection rectangle around an annotation when the user clicks on it, and remove it when he clicks away? I’ve spent a lot of time trying to come up with a solution, but no luck.
The solution that works with MacOSLib is to place a PDFAnnotationSquare over the annotation and display just the square’s border. When the user clicks on the square the underlying annotation is selected (text, highlight, etc.). When I do the same thing with MBS the PDFAnnotationSquareMBS always gets the mouse click, it’s never received by the actual underlying annotation. Why the PDFAnnotationSquare behaves differently in MacOSLib and MBS I don’t know. I can change the z order by removing the annotation, adding the square annotation, and adding back the original, but that’s ugly and has it’s own problems. I don’t see a way to either add the square annotation below the annotation clicked on or to let the click “pass through” the PDFAnnotationSquareMBS to the underlying one.
Using the border property of the annotation. This would seem to be possible from the Apple docs, but unlike PDFAnnotationSquareMBS, PDFAnnotationTextMBS and others have a border = nil. I would seem possible to create a PDFBorderMBS and add it to the annotation, but the PDFBorderMBS constructor is private.
It seems you can’t simply draw a selection rectangle around the annotation in any of the DrawPage events because they don’t occur in the main thread and the plugin is ignored.