• 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: Changing the behavior of 'Return' in NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing the behavior of 'Return' in NSTableView


  • Subject: Re: Changing the behavior of 'Return' in NSTableView
  • From: John Shockey <email@hidden>
  • Date: Thu, 12 Jul 2007 07:35:01 -0400

On Jul 12, 2007, at 5:51 AM, Michael Fey wrote:

I have code in place such that when the user adds a row to the table it automatically begins editing the cell in the first column of the new row. However, when the user hits the Return key, I'd like that cell to break out of editing mode and keep the current row selected instead of the default behavior of moving on to the next row.

The following worked for me in a program I wrote a while ago.


Have the table's delegate implement:

- (BOOL) control: (NSControl *) control textView: (NSTextView *) textView doCommandBySelector: (SEL) command

If the control is your table view, and the command is @selector (insertNewline:), call

[yourWindowWhichYouGetFromSomewhere makeFirstResponder: control];

and return YES


[control window] should be one way to get the window, though in my case I had it available even more easily.


You can obviously use this method to alter the behavior of many of the keys bound to specific effects. (For a list of many possible selectors, see the documentation for NSResponder.)

I hope that helps.

John Shockey

john ATSIGN johncshockey DOT com


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Changing the behavior of 'Return' in NSTableView
      • From: Michael Fey <email@hidden>
References: 
 >Changing the behavior of 'Return' in NSTableView (From: Michael Fey <email@hidden>)

  • Prev by Date: Dock Size and Position
  • Next by Date: NSNumberFormattter not working
  • Previous by thread: Changing the behavior of 'Return' in NSTableView
  • Next by thread: Re: Changing the behavior of 'Return' in NSTableView
  • Index(es):
    • Date
    • Thread