Table of Contents (Sidebar) for Cocoa Program Help

I am creating a reference book for my application, mainly using the Apple documentation here , however it seems to be a bit dated. In Yosemite OS X 10.10, native Apple apps have a collapsible sidebar that displays the table of contents for the help pack

Mail App Help Book

Although the sidebar button is present in my own application, I have no idea how to access it. Does anyone know how to access this sidebar? and provide content for our own applications?

+6
source share
1 answer

I just ran into the same problem and I had to dig into the Apple Mail help files to find out what they use. They basically created their sidebar in HTML / CSS, and part of it is not part of the help viewer.

To enable the table of contents button in the help viewer, you need to use the javascript function:

window.HelpViewer.showTOCButton(bool, function, function); 

For a more explicit example, the following code snippet will enable the "Table of Contents" button in Apple Help Viewer and associate it with the "toggleNavigation" function.

 if ("HelpViewer" in window && "showTOCButton" in window.HelpViewer) { window.setTimeout(function () { window.HelpViewer.showTOCButton(true, toggleNavigation, toggleNavigation); window.HelpViewer.setTOCButton(true); }, 100); } 

The toggleNavigation function will contain the code to open the sidebar.

 function toggleNavigation() { // YOUR CODE HERE } 

I found that using window.onload does not work, but setting a timeout of 100 ms. In Mail, Apple used the equivalent of the "toggleNavigation" function for both function parameters, as shown in the example. The third parameter is called when you click the "Table of Contents" button, but I have not determined what the second is for.

+3
source

Source: https://habr.com/ru/post/978787/


All Articles