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

后端 未结 1 528
野性不改
野性不改 2020-12-31 18:27

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, a

相关标签:
1条回答
  • 2020-12-31 18:44

    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.

    0 讨论(0)
提交回复
热议问题