home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!agate!darkstar.UCSC.EDU!cats.ucsc.edu!isbell
- From: isbell@cats.ucsc.edu (Art Isbell)
- Newsgroups: comp.sys.next.programmer
- Subject: Re: dbkit delete
- Date: 7 Nov 1992 18:39:34 GMT
- Organization: Cubic Solutions - NeXT software development and consulting
- Lines: 62
- Message-ID: <1dh2h6INNbnr@darkstar.UCSC.EDU>
- References: <1992Nov6.175547.5655@rdr.com>
- NNTP-Posting-Host: si.ucsc.edu
-
-
- In article <1992Nov6.175547.5655@rdr.com> lovelace!kswanson (Kevin Swanson) writes:
- >
- >has anyone played with the dbfetchgroup method setAutoSelect?
- >what i wanted to use it for was automatically selecting the next record
- >in the recordlist after a deletion. i've tried other things, like using
- >setCurrentRecord, but something always resets it to select record 0.
-
- Well, I guess I'm going to have to print the 3.0 DBKit docs after all.
- setAutoSelect: was not available in 3.0 PR2, so I didn't even realize it
- exists. And unfortunately, as is the case with much of NeXT's method
- documentation, the default is not stated :-( The behavior I see seems similar
- to autoSelect being on, except the record selected after any operation (delete,
- insert, append, etc.) seems to be record 0.
-
- So I've implemented all database operations like the attached deleteRecord:
- method to force the selection of a specific record:
-
- - deleteRecord:sender
- {
- unsigned currentRecord = [fetchGroup currentRecord];
- id returnValue = nil;
-
- // Prevent ugly visible changing of the TableView selection.
- [window disableFlushWindow];
-
- // Give user a chance to change her mind, but go ahead and save changes to
- // database if user proceeds.
- if ((NXRunLocalizedAlertPanel(NULL, NULL,
- "Deletion of this record cannot be undone.", "Delete", "Don't delete",
- NULL) == NX_ALERTDEFAULT) &&
- (returnValue = [modifyModule deleteRecord:sender]) &&
- (returnValue = [modifyModule saveChanges:sender]))
- {
- // Make sure at least one record remains.
- if ([fetchGroup recordCount] > 0)
- {
- // Set current record to the record immediately following the
- // deleted record. If the deleted record is the last one, the last
- // record will be selected automatically.
- [fetchGroup setCurrentRecord:currentRecord];
-
- // Select the first TextField on the Window.
- [firstText selectText:self];
- }
- }
- [[window reenableFlushWindow] flushWindowIfNeeded];
- return returnValue;
- }
-
- I really wish that NeXT would change its method documentation format from the
- free-form style to a structured style. This might result in essential info
- like default settings, pre- and post-conditions, decent argument descriptions,
- changes to instance variables, return values and conditions under which various
- values are returned, side effects, etc. not being omitted as seems to happen
- far too often as it now stands. But this is another topic...
- --
-
- Art Isbell Cubic Solutions
- NeXT Registered Developer #745 NeXT software development and consulting
- Email: isbell@cats.UCSC.EDU Voice: (408)335-1154
- USmail: 95018-9442 Fax: (408)335-2515
-