CTFontManagerRegister... for a 3rd-party app - macos

This is a bit basic but I have been struggling finding good documentation around NSFontManager and CTFontManager to achieve this. So here's the scenario:
Keynote (or any other existent app from a different developer) opens a file which uses a font that's not activated.
My app has the font and I use CTFontManagerRegisterFontURLs or one of the similar methods to get it activated.
Keynote gets a notification that the font is now available.
I would imagine there's a NSFontManager notification for missing fonts, but haven't found anything. The notifications seem to be within the sandbox of my own app. Does anyone here have an idea where I can find anything that does this (or almost does this)?
Thank you so much.

Related

How to best author a Apple Helpbook for a macOS app?

macOS apps, e.g. Photos.app, provide a help panel to the user
Is there a way to author such a Help Book in your own macOS app?
Is there a way to at least provide a toolbar to be used for a table of contents?
I am asking specifically about the UI and all the user interactions. Not how to generally create and register a helpbook.
Update
Here is what I’ve been able to find/gather/learn from others. A Help Book appears to run on a separate app/process called “HelpViewer”. Any Apple macOS app displaying a help makes use of a DDMViewerController that isn’t public.
There is an “app.css” and an “app.js” being used by the Apple macOS app “index.html” of the Apple Help Book. The Javascript one manipulates the DOM to create the “show-hide” link that toggles the Sidebar. Haven’t been able to find how to instruct HelpViewer to use a sidebar.
There is a WWDC talk from back in 2014, “Introducing the Modern WebKit API” that talks about “User Scripts” and “Script Messages” which allow communication between a Webview and Cocoa. https://developer.apple.com/videos/play/wwdc2014/206/
AFAICS, there is no way to have HelpViewer display a custom view or have a sidebar. My guess is that you would have to implement everything yourself. That is an NSSplitViewController, NSToolbar, NSOutlineView, any Javascript alongside the “app.css” to get the look and feel.
Currently it's not possible to implement the sidebar as shown in the Maps and other built-in macOS applications from 10.13 onward.
Versions of macOS from 10.10 (built-in applications) implement sidebar navigation with HTML and JavaScript, and Apple Help Viewer itself offers a window.HelpViewer object with some hooks that enable/disable the Help Viewer's table of contents button. Once enabled, it will callback into your own JavaScript where you can show/hide TOC via CSS or JS.
From approximately 10.10, Apple's non-built-in applications have also been using this technique. For example, iTunes and Xcode help both do this.
From 10.13, macOS has a newer version of Help Viewer that provides an actual Cocoa-native table of contents and windows splitter, as well as some new properties on window.HelpViewer; presumably these can be used to enable/disable the Cocoa sidebar and populate the TOC, but these are undocumented and I'm not sure anyone outside of Apple has been able to reverse-engineer this functionality yet.
And in any case, it wouldn't work if you offer Help Books to pre-10.13 users, and the use of undocumented API's restricts applications from the App Store (although, I'm not certain that Apple scans Help Book JavaScripts for API usage as part of their review).
(There are also a lot of other changes to how Apple's built-in application Help works now, too, but that's another topic entirely.)
Thus the answer for now is we can't, or shouldn't, or just don't know how. Alternatives include using something like using jekyll-apple-help (no affiliation) or Middlemac 3 (my project), or just rolling your own.
For those interested in knowing how Apple does it, I've documented a lot of it here (disclosure: link to my own website).
I'm not sure whether Apple's current applications still use it, but there is a very old API on macOS for Help Books. Apple has documentation on how to create them and some introduction. In short: Help books are standard HTML files with additional proprietary anchors. Those anchors are accessible via the class NSHelpManager, e.g. to open the help book at a specific page.
See also this question.

Can anyone help me think of an app that uses a set of almost wireframe instructional elements before the user starts using the app?

Can anyone help me think of an app that uses a set of almost wireframe instructional elements before the user starts using the app? I know I have used a few apps like that. They will show a stencil of a hand and show you how to work through the app. I am working on a UX exercise and I need some ideas on how to incorporate something like that into my project to help the user to get up and running faster in my application. Any help would be much appreciated.
Yes, that pattern is called "coach marks" and is available in many apps. You can see it on The Weather Channel's new weather app for the iPhone or iPad (shameless plug). There is also a reference on coach marks, with many examples which can be found here.

Detecting Full screen applications on mac

I am developing a simple application in Cocoa, and I want to detect whether any application is running in full screen mode. Is this possible?
Through runningApplications API, I can get various informations but there is no specific property related to full screen mode. Does any one know how to detect it? Is there any carbon event or API for this?
I ran into this in the spring and spent forever trying to get it to work. I ended up packaging my code up into a little GitHub project, but I completely forgot to share it here.
https://github.com/shinypb/FullScreenDetector
Hope this is useful for someone.
Anyways after trying out so many options and digging into the NSWorkspace i have found way through which we can achieve this their is notification
"NSWorkspaceActiveSpaceDidChangeNotification"
Apple doc says "Posted when a Spaces change has occurred." so by using we can register for it. along with this we need to use the NSWindow's property "isOnActiveSpace" , so by this we can detect when application enters full screen mode and exits from it.
You want to key-value observe -[NSApplication currentSystemPresentationOptions]. When the active app is in full-screen mode, that property will include NSApplicationPresentationFullScreen.

Creating Universal UI files

Is there any tutorial available for creating Universal UI which can run on iPad as well as iPhone on different resolution. I tried looking in the official documentation, but couldn't find anything about UI files.
I notice you've tagged this question with Marmalade, so I'm assuming you are talking about how to write a Universal app in Marmalade? If so then creating a Universal UI is pretty much up to you to implement in the best way you see fit.
By default all Marmalade apps are Universal apps, though you can limit to iPad only with the MKB setting iphone-ipad-only.
Marmalade does come with the iwui module that allows you to lay out user interfaces with buttons and text boxes etc. but ultimately unless you have a very simple UI you'll need to either provide different UI layouts for each screen resolution/orientation you wish to support, or do some fancy laying out in code.
Apple wisely chose to persuade developers into creating separate UIs for iPhone and iPad since the one-layout-fits-all approach generally looks bad at any screen size.

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).

Resources