🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
2 messages
2 total messages Started by lovelacekswanson Kevin Swanson Fri, 06 Nov 1992 17:55
dbkit delete
#1368
Author: lovelacekswanson Kevin Swanson
Date: Fri, 06 Nov 1992 17:55
13 lines
802 bytes
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.

anyone with similar problems? any ideas?

thanks,
kevin


kswanson@rdr.com
Re: dbkit delete
#1372
Author: Art Isbell
Date: Sat, 07 Nov 1992 18:39
62 lines
3348 bytes
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads