ProtoPeoplePicker Name Display Changed in Newton 2.1

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.


NEW: ProtoPeoplePicker Name Display Changed in Newton 2.1 (7/2/97)

Q: In Newton OS 2.0, the protoPeoplePicker displayed names as "last, first", but in Newton 2.1 OS it displays "first last". How can I make protoPeoplePicker display the original way?

A: You will need to create a subclass of the nameRefDataDef for people that will display the name in "last, first" format. The good news is that this workaround will work on both Newton 2.0 and Newton 2.1. The basic steps are:

1. Register your own subclass of nameRefDataDef that does the right thing

2. Use this new data def class in the dataClass slot of your peoplePicker

3. Unregister your subclass when you are done (for instance, when quitting the application)


Here is some code that can be used to register a subclass. Put the following in a text file in your project:

    // create a unique symbol for the the data def
    DefineGlobalConstant('kMyDataDefSym,
        Intern("nameRef.people.lastFirst:" & kAppSymbol)) ;

    DefineGlobalConstant('kMyGetFunc,
        func(item, fieldPath, format)
        begin
            // if this is a person, not a company, modify stuff
            local entry := EntryFromObj(item) ;
    
            if fieldPath = 'name AND format = 'text AND entry AND 
                IsFrame(entry) AND ClassOf(entry) = 'person then
            begin
                local nameFrame := entry.name ;
                if nameFrame AND nameFrame.first AND nameFrame.last then
                    return nameFrame.last & ", " & nameFrame.first ;
                else
                    return inherited:Get(item, fieldPath, format) ;
            end 
            else
                return inherited:Get(item, fieldPath, format) ;
        end
    ) ;


Put this code into the viewSetupFormScript of the base view of your application:

            // register my modified people data def
        RegDataDef(kMyDataDefSym, {_proto: GetDataDefs('|nameRef.people|),
                        Get: kMyGetFunc}) ;


Put this code into the viewQuitScript of the base view of your application:

        // unregister my modified people data def
        UnRegDataDef(kMyDataDefSym) ;



Use the kMyDataDefSym constant as the value for the dataClass slot of your protoPeoplePicker or protoPeoplePopup