• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTableView custom behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView custom behavior


  • Subject: Re: NSTableView custom behavior
  • From: John Morgan <email@hidden>
  • Date: Thu, 22 Dec 2005 23:03:58 -0800

Hi,

I implement something similar to this code below in the NSTableView delegate. The tableView and arrayController instance variables are outlets to the NSTableView and NSArrayController (which is set to 'Selects Inserted Objects').

- (void)applicationDidFinishLaunching:(NSNotification *)note {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textEndEditing:) name:NSTextDidEndEditingNotification object:nil];
}

- (void)textEndEditing:(NSNotification *)note {
NSEvent *theEvent = [NSApp currentEvent];

if ([theEvent type] == NSKeyDown) {
unichar keyDownCharacter = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];

if ([[[note object] superview] superview] == tableView) {
if (![arrayController canSelectNext] && [tableView columnAtPoint:[[note object] frame].origin] == [tableView numberOfColumns] -1 && keyDownCharacter == NSTabCharacter) {

NSManagedObject *newRow = [[NSManagedObject alloc] initWithEntity: [NSEntityDescription entityForName:[arrayController entityName] inManagedObjectContext:managedObjectContext] insertIntoManagedObjectContext:nil];
[arrayController insertObject:newRow atArrangedObjectIndex:[[arrayController arrangedObjects] count]];
[tableView editColumn:0 row:[tableView selectedRow] withEvent:nil select:YES];
[newRow release];
}
}
}
}


This may not be the fastest or best way of doing it, as I am learning myself, but it seems to work for me.

HTH,
John Morgan


On Dec 22, 2005, at 7:18 PM, Robert Walker wrote:

Dear List,

I need some assistance adding some custom behavior to an NSTableView. I'm using a NSArrayController with CodeData bindings to populate the table. This application requires high speed data input, and I would like to automatically insert a new NSManagedObject to the NSArrayController when the user tabs past the last cell, on the last row of the table.

I'm have trouble finding the right place to hook into the tabbing process and select the first column of the newly inserted row. This will allow the user to insert multiple rows of data without having to click a button or press a keyboard shortcut.

Thanks, and sorry for the noob question, but I'm just getting started with Cocoa. I have been developing mostly in WebObjects for the past few years. My goal is to create a Cocoa client application that communicates with my WebObjects application via web services. This will provide my clients with a much more elegant user experience than what they currently have in JavaClient for WebObjects.

--
Robert Walker
email@hidden

There are 10 types of people in the world, those who count in binary, and those who don't.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: NSTableView custom behavior
      • From: John Morgan <email@hidden>
References: 
 >NSTableView custom behavior (From: Robert Walker <email@hidden>)

  • Prev by Date: Image Name retrival from web page - Objective C
  • Next by Date: Re: NSTableView custom behavior
  • Previous by thread: NSTableView custom behavior
  • Next by thread: Re: NSTableView custom behavior
  • Index(es):
    • Date
    • Thread