How to Programmatically Open the Header Slip

One of the Newton 2.x OS Q&As
Copyright © 1997 Newton, Inc. All Rights Reserved. Newton, Newton Technology, Newton Works, the Newton, Inc. logo, the Newton Technology logo, the Light Bulb logo and MessagePad are trademarks of Newton, Inc. and may be registered in the U.S.A. and other countries. Windows is a registered trademark of Microsoft Corp. All other trademarks and company names are the intellectual property of their respective owners.


For the most recent version of the Q&As on the World Wide Web, check the URL: http://www.newton-inc.com/dev/techinfo/qa/qa.htm
If you've copied this file locally, click here to go to the main Newton Q&A page.
This document was exported on 7/23/97.


How to Programmatically Open the Header Slip (1/3/97)

Q: I like the way the Newton Works application (for Newton 2.1 OS) automatically opens the header slip each time a new entry is created. Can I make my newtApp-based application do this?

A: Yes! The newtEntry(Roll/Page)Header proto has a PopIt method which opens the header. You will need to override the StatScript of your newtNewStationeryButton and send the header a PopIt message. Because PopIt is not defined prior to Newton 2.1 OS, you will need to check for its existence before calling it. Here is a code example:

    newtNewStationeryButton.    StatScript: func( theStat )
        begin
            // Keep a copy of the inherited return value for use below
            local result := inherited:?StatScript( theStat );

            // Pass self as a parameter for the closure.  This gives us a reference
            // to the application so we can get the entry view.
            AddDeferredCall( func( context ) 
                                begin
                                    local entryView := context:GetTargetView();

                                    // This code assumes that your header is declared to the entry
                                    // view with the name theHeaderView
                                    if entryView.theHeaderView.popIt then
                                        entryView.theHeaderView:Popit( true );
                                end, 
                            [self] );

            result;
        end;