A CheckAll Button for NewtApp Overviews

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.


A CheckAll Button for NewtApp Overviews (3/4/97)

Q: What do I have to do to get the Check All button to appear in my overview? What's the compatible way to do this so that the application works on Newton 2.0 OS as well?

A: In Newton 2.1 OS, there is a proto called newtCheckAllButton (@872) which you can use. This proto sends the CheckAll method to the layout. In Newton 2.1 OS, newtOverLayouts have two new methods, CheckAll and UncheckAll, which implement this behavior. However, none of this is present in Newton 2.0 OS .

To create a check all button that works on the Newton 2.0 OS, you will need to create the button yourself and implement the CheckAll and UncheckAll methods for your overview layout (or any other layout you wish to implement check all for.)

Older versions of the DTS sample code (either "Checkbook-7" or "WhoOwesWhom-3") do have a protoCheckAllButton. These samples implement an earlier (and less useful) flavor of Check All. The old samples check all the items which are currently visible in the overview, while the Newton 2.1 OS checks all the items that are present in the currently selected folder/card filter. "Checkbook" (version 8 or later) or "WhoOwesWhom" (version 3 or later) will reflect the Newton 2.1 behavior.

Until the updated samples are available, start with the protoCheckAllButton from the older sample code, since that gives the correct look and button bounds, and modify it as follows:

The check all button's buttonClickScript should look something like this:
   func()
        if newtAppBase.currentLayout = 'overView then
            begin
                if layout.checkAllPrimed then
                    layout:UnCheckAll()
                else
                    layout:CheckAll();
                layout.checkAllPrimed := NOT layout.checkAllPrimed;
            end;


The overview layout's CheckAll and UncheckAll methods should look something like this:

    CheckAll:
        func()
            begin
                local curse := dataCursor:Clone();
                curse:Reset();
                hilitedIndex := nil;
                selected := MapCursor(curse, func(e) MakeEntryAlias(e));
                AddUndoSend(layout, 'UnCheckAll, []);
                layout:DoRetarget();
            end;

    UncheckAll:
        func()
            begin
                hilitedIndex := nil;
                selected := nil;
                layout:DoRetarget();
            end


Note that these methods make use of two undocumented slots: hilitedIndex and selected. hilitedIndex is used internally by newtOverLayout to track the tapped item. You may set it to NIL (as above) to clear the value, but do not set it to some other value or rely on its current value. selected contains an array of aliases to soup entries representing the currently selected items, and will be used by the routing and filing buttons for processing entries. It is important to clear hilitedIndex when modifying the selected array in any way.

The resulting CheckAll button should be included in the menuRightButtons array for the status bar. The older sample code puts it on the left, however user interface discussions as part of the Newton 2.1 OS effort resulted in the decision to place the button on the right.