> On Nov 14, 2013, at 8:04 AM, Trygve Inda <cocoa...@xericdesign.com> wrote:
> 
>>> On Nov 14, 2013, at 12:54 AM, Trygve Inda <cocoa...@xericdesign.com> wrote:
>>> 
>>>> I have a NSTableView backed by an NSArrayController.
>>>> 
>>>> If I am editing a cell in a row in the tableview and call addObject on the
>>>> NSArrayController (to add a new row to the tableview), my editing session
>>>> for some other row is ended.
>>>> 
>>>> addObject is called from an NSNotification method when some other event
>>>> happens in the app the requires a row be added to the table.
>>>> 
>>>> How can I prevent the edit session from ending.?
>>> 
>>> In the docs, - (BOOL)selectionShouldChangeInTableView:(NSTableView
>>> *)aTableView is used for this purposeā€¦
>>> 
>>> HTH,
>>> 
>>> Keary Suska
>>> Esoteritech, Inc.
>>> 
>>> 
>>> 
>> 
>> Note that when the new row is added, the selection does not change, but the
>> editing of the cell is forced to end. The selection changes from a blue
>> highlight to a grey one.
> 
> 
> This is not because you are adding a row per se, but because the action is
> changing the first responder. If you don't want to allow changing the first
> responder you will need to subclass (the table view, cell, or window) to
> refuse to resign first responder status under the desired conditions.
> 


In my table delegate I implement:

- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText
*)fieldEditor
{
    if ([[fieldEditor string] length] == 0)
        return NO;    // don't allow empty names
    else
        return YES;
}

This works when editing a cell in a table row when I press return

If I change this to:

- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText
*)fieldEditor
{
        return NO; 
}

And start an edit session, if addObject is called on the ArrayCOntroller
feeding the tableView, the cell edit session ends without this method ever
being called. 

However: - (void)controlTextDidEndEditing:(NSNotification *)obj

IS called.

How can I prevent the edit session from ending when adding items to the
array controller feeding the table view?




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to