Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Table Of Contents(Side Bar) for Cocoa App's Help Book

I'm in the process of building a help book for my application, mainly using apple's documentation here, however it appears to be a little dated. In Yosemite OS X 10.10, apple's own apps have a collapsable side bar that displays the table of contents for the help bundle

Mail App Help Book

Although, the side bar button is present on my own app I have no idea how to access it. Does anyone know how to access this sidebar? and provide content for our own apps?

like image 753
Cory Avatar asked Nov 27 '14 12:11

Cory


1 Answers

I've just come up against the same problem, and I had to dig around in Apple Mail's help files to find out what they were using. Basically they have constructed their sidebar in HTML/CSS, and its not a 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's help viewer, and link it to the function "toggleNavigation".

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 code to open your sidebar.

function toggleNavigation() {
    // YOUR CODE HERE
}

I found that using window.onload doesn't seem to work, but setting a timeout for 100ms did. In Mail, Apple used their equivalent of the "toggleNavigation" function, for both of the function parameters, as per the example. The third parameter is called when you press the "Table of Contents" button, but I've not worked out what the second one is for.

like image 110
JonLord Avatar answered Oct 07 '22 16:10

JonLord