Adding a New Editor to People in Names

The InfoFrame in the viewDef

The second slot is a requirement of the Names application for viewDefs which are used within it. The Names application requires an infoFrame slot. This slot provides information to the Names application about:

6. Add this infoFrame slot of the clView:

{
   // slot where data is stored
   checkPaths: [kColorSlotSym],         
   
   // First item in array specifies that 
   // first instance of color
   // is stored directly in the soup entry. 
   // Second item specifies
   // that multiple instances aren't allowed
   checkPrefix: [true, nil],      
   
   // <data> is an array containing the color       
   formatFunc: func(data)                
   begin          
      if StrFilled(data[0]) then
         "Favorite color: " && data[0];   
      else
         "";
   end,
}
The checkPaths tells the Names application that our viewDef uses one slot. The checkPrefix slot tells the Names application that the first instance of our viewDef uses slots at the top level of the soup entry. If the second item in the checkPrefix array were a symbol, it would specify a slot in the soup entry that would contain an array of additional frames. The third slot, formatFunc, is a function which returns a string used in the All Info display. It is called with an array of data (the slots specified in the checkPaths array) and returns a string to display.

To give you a quick comparison, take a look at the infoFrame of the e-mail viewDef to see how it differs:

{
   checkPaths: ['email, 'emailPassword], 
   checkPrefix: [true, 'emailAddrs], 
   formatFunc: ...
}
This viewDef uses two slots (email and emailPassword) rather than just one. It's checkPrefix specifies that if the first time E-Mail is chosen from the Add picker, the slots email and emailPassword are added directly to the soup entry. The second time E-Mail is chosen, an emailAddrs slot is created in the soup entry as an array. Third and subsequent times, the emailAddrs array is enlarged.


Note:When a Names viewDef is instantiated, the selectedPath slot is set; it specifies where the data should be edited. With a value of nil, the checkPaths slot directly in the soup should be edited. A value of [pathExpr: 'emailAddrs, 0] would specify that the email and emailPassword slots within emailAddrs[0] should be edited. It is then up to the viewDef to edit the data from the correct frame.


7. Add the layout file to the project, naming it "ColorEditorViewDef.t".


An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996