Displaying pdf files using the PDFKit interface - cocoa

I am working on a Mac OS 10.12, and have an application to display pdf files using the PDFKit interface.
But I encountered the following issues
Set pdf document to PDFView, in original OS,e.g. OS10.11 , there will invoke PDFView->drawPage() function, but in OS10.12,the function is not invoked;
PDFView can't draw pdf annotation in OS10.12;
Solution to the above will be appreciated

I reckon this is either a straight out bug or an as yet undocumented API change. I logged this as a bug (27666426) and can see now that it is being flagged as an open duplicate (27668895).
Note that of 10.12 Beta 6 -drawWithBox:toContext: gets called in place of the now deprecated -drawWithBox:. Note that it is also necessary to use the passed in context for all drawing.
UPDATE:
However things do not seem that simple with the 10.12 now that it is released. I find that my PDF view printing, which is driven off of -drawWithBox: on 10.11 and -drawWithBox:toContext: on 10.12+ is broken.
Stepping through the assembler I can see that 10.12, when printing, now calls -drawWithBox:inContext: not -drawWithBox:toContext: or -drawWithBox: (as was the case on 10.11). It would seem that the inContext: selector has been around a while.
It would seem that the only solution that works on 10.9 - 10.12 for both screen and print renders is to use the undocumented -drawWithBox:inContext:.

Related

Mac browser cursor link behavior

I noticed the strangest behavior on my Mac (macOS Big Sur 11.6, Apple M1) in any browser (Firefox 96.0, Chrome 97.0.4692.71).
When my cursor hovers over a link, it turns into a hand for an instant and goes back to an arrow straight away. It's like it wants to show the correct cursor, and then overwrites it.
Even having an !important to the CSS property of a link doesn't change this behavior.
Does anyone have an idea how to change this?
A video of the behavior, W3C page is used via WeTransfer:
https://wetransfer.com/downloads/37b8e4a034cbeee674fb480bf055144f20220114093334/77efdb
On an other computer (macOS Big Sur 11.2, Intel Core) I don't have this weird behavior.
I can't find anything decent online about this, my apologies if it's already mentioned somewhere.
After a few hours the behavior was gone.
An entire reboot would probably have solved it too (I only shut down the browsers and even upgraded them, but even that didn't change the behavior).
As Jaime S mentioned, this issue also mentions it CSS cursor pointer flicker once and then back to default

opengl viewport in Mac with FMX delphi

I have designed an application in Delphi FMX that uses a new component based on class TPresentedControl. This component presents the output of opengl functions. (something like drawing in a viewport with opengl).
In Windows application runs successfully, but in MacOS it runs without this opengl viewport.
You can see a relative discussion here: https://forums.embarcadero.com/thread.jspa?threadID=248299
Do I have to use NSOpenGLView instead of my component?
If not what other options do i have?
For whoever is interested,
in GitHub (https://github.com/tothpaul/Firemonkey/tree/master/GLPanel) a developer named Friedrich Westermann
opened a new pull request for Pauls Toth' code in which he wrote a new part with code for Mac and also some changes to the existed.
I have tested it and works perfectly on Mac.

CGrafPtr to WindowRef

NPAPI in MacOs gives me CGrafPtr in NPWindow structure, I need a WindowRef.
Is there a way to get WindowRef from CGrafPtr ?
Thanks!
NPAPI only gives you a CGrafPtr if you are using the very, very deprecated QuickDraw drawing model (with Carbon event model). Writing a new plugin using the QuickDraw model would be a terrible idea: Firefox 64-bit doesn't support it, Safari 64-bit doesn't support it, and Chrome doesn't really support it (and soon won't at all). Your plugin wouldn't work for most users.
Instead, you should be using either Core Animation (drawing) + Cocoa (event), or CoreGraphics + Cocoa. In the Cocoa event model there is, deliberately, no way to get a reference to the browser window. Modern browsers almost all run plugins in a separate process, and you can't reference windows across processes.
In short, if you are trying to make a new NPAPI plugin that requires access to the browser window, your design is wrong.

How to implement "Open With" contextual menu in OS X

Apps in OS X that can open files to launch their respective applications often let the user choose the app that'll open the file. An example is the Finder.
I am still unclear about what's the best solution to implement this. The challenges are performance and showing the app's icon.
First, to get the list of apps, I found only LSCopyApplicationURLsForURL().
The major difficulty for me now is to get the app icons. All I have is the URLs (paths) to the apps. The only way I know of to get the icons would be to create a CFBundle object and then read the app's plist to get the icon data. But that appears to invole lots of disk access, and I could imagine it'll be quite inefficient if the app is located on a remote file server.
I believe that there's also a cached database about the apps, which includes icons and display names (without extension), and such. But where is the API for that?
Note: The app is Carbon based, but I can make use of Cocoa (NS...) functions if necessary. Also, Support for 10.5, even 10.4, would be appreciated.
Alright. I solved it eventually.
I now use the Carbon function GetIconRefFromFileInfo(), which still works in Lion, though it's marked deprecated/obsolete.
I had also tried to use QLThumbnailImageCreate(), but that didn't get me any results, oddly. No idea what I did wrong.
For Cocoa apps, [[NSWorkspace sharedWorkspace] iconForFile:path] can be used (thanks to C. Grunenberg of DevonTechnologies for this tip, where it's used with EasyFind).

Firefox 3.6 plugins fail on Mac?

I just upgraded my mac to Firefox 3.6, and now neither of my TIFF Viewing plugins work.
in 3.5, If I had Quicktime on, then I'd get the tiff, viewed through quicktime. If I had Quicktime disabled, but my own plugin, AcellViewTIFF enabled, then I would get ViewTIFF viewing the TIFF. Since I'm the author of ViewTIFF, That's how I had it most of the time.
After I upgraded to 3.6, if ViewTIFF is enabled, I just get a blank space. if ViewTIFF is disabled, no matter whether or not Quicktime is enabled, it goes straight to preview.
Has anyone seen this?
(This is programming related because I'm writing AccelViewTIFF, and if the framework for plugins changed, I need to fix it...)
Edit to add:
This is an NPAPI plugin, I've removed or commented out the main, so I don't think that this is a CFM plugin problem.
I looked at Mozilla's "basicplugin" (located in mozilla-1-9-1-f15a2686e9a6/modules/plugin/sdk/samples/basic/mac under the standard mozilla source) and it works. I compared all of my functions to the functions in BasicPlugin, and the only function that it has that I don't is the drawPlugin function, which appears to do the actual work. All equivalent functions have the same interface.
When I remove or disable AccelViewTIFF, Firefox downloads the image and gives it to preview. When I enabled it it does nothing. This tells me that Firefox IS seeing that I have a plugin, but it's not running it for some reason.
There are no errors either in Firefox's error console or in any of the console logs I can see...
any ideas?
For the record, the problem was that this is an OLD plugin that still uses Quickdraw routines. evidently, they didn't make it into 64b, and so they don't work in FF 3.6.
Lets hear it for progress.
Are you using Leopard or Snow Leopard?
TIFF files open fine with the QuickTime 7.6.3.0 plugin with Firefox 3.6.
Go to Firefox -> Preferences -> Applications. Search for "tif" and then you can choose how Firefox handles files with the image/tiff MIME type. Set it to the plugin of your choosing. QuickTime should work (is for me on Snow Leopard).

Resources