home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / next / programm / 7088 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  3.2 KB

  1. Path: sparky!uunet!stanford.edu!agate!darkstar.UCSC.EDU!cats.ucsc.edu!isbell
  2. From: isbell@cats.ucsc.edu (Art Isbell)
  3. Newsgroups: comp.sys.next.programmer
  4. Subject: Re: dbkit delete
  5. Date: 7 Nov 1992 18:39:34 GMT
  6. Organization: Cubic Solutions - NeXT software development and consulting
  7. Lines: 62
  8. Message-ID: <1dh2h6INNbnr@darkstar.UCSC.EDU>
  9. References: <1992Nov6.175547.5655@rdr.com>
  10. NNTP-Posting-Host: si.ucsc.edu
  11.  
  12.  
  13. In article <1992Nov6.175547.5655@rdr.com> lovelace!kswanson (Kevin Swanson) writes:
  14. >
  15. >has anyone played with the dbfetchgroup method setAutoSelect?
  16. >what i wanted to use it for was automatically selecting the next record
  17. >in the recordlist after a deletion. i've tried other things, like using
  18. >setCurrentRecord, but something always resets it to select record 0.
  19.  
  20. Well, I guess I'm going to have to print the 3.0 DBKit docs after all.
  21. setAutoSelect: was not available in 3.0 PR2, so I didn't even realize it
  22. exists.  And unfortunately, as is the case with much of NeXT's method
  23. documentation, the default is not stated :-(  The behavior I see seems similar
  24. to autoSelect being on, except the record selected after any operation (delete,
  25. insert, append, etc.) seems to be record 0.
  26.  
  27. So I've implemented all database operations like the attached deleteRecord:
  28. method to force the selection of a specific record:
  29.  
  30. - deleteRecord:sender
  31. {
  32.     unsigned currentRecord = [fetchGroup currentRecord];
  33.     id returnValue = nil;
  34.  
  35.     // Prevent ugly visible changing of the TableView selection.
  36.     [window disableFlushWindow];
  37.  
  38.     // Give user a chance to change her mind, but go ahead and save changes to
  39.     // database if user proceeds.
  40.     if ((NXRunLocalizedAlertPanel(NULL, NULL,
  41.         "Deletion of this record cannot be undone.", "Delete", "Don't delete",
  42.         NULL) == NX_ALERTDEFAULT) &&
  43.         (returnValue = [modifyModule deleteRecord:sender]) &&
  44.         (returnValue = [modifyModule saveChanges:sender]))
  45.     {
  46.         // Make sure at least one record remains.
  47.         if ([fetchGroup recordCount] > 0)
  48.         {
  49.            // Set current record to the record immediately following the
  50.            // deleted record.  If the deleted record is the last one, the last
  51.            // record will be selected automatically.
  52.             [fetchGroup setCurrentRecord:currentRecord];
  53.  
  54.             // Select the first TextField on the Window.
  55.             [firstText selectText:self];
  56.         }
  57.     }
  58.     [[window reenableFlushWindow] flushWindowIfNeeded];
  59.     return returnValue;
  60. }
  61.  
  62. I really wish that NeXT would change its method documentation format from the
  63. free-form style to a structured style.  This might result in essential info
  64. like default settings, pre- and post-conditions, decent argument descriptions,
  65. changes to instance variables, return values and conditions under which various
  66. values are returned, side effects, etc. not being omitted as seems to happen
  67. far too often as it now stands.  But this is another topic...
  68. -- 
  69.  
  70. Art Isbell                                                      Cubic Solutions
  71. NeXT Registered Developer #745         NeXT software development and consulting
  72. Email: isbell@cats.UCSC.EDU                                Voice: (408)335-1154
  73. USmail: 95018-9442                                           Fax: (408)335-2515
  74.