Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7752117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:43:03+00:00 2026-06-01T11:43:03+00:00

I currently have a tableview, with cell views which have NSTextFields inside of them.

  • 0

I currently have a tableview, with cell views which have NSTextFields inside of them.
Currently, on row select, I’m sending the cell view the following message with the hope of granting the NSTextView in the cell view first responder status:

- (void)notifyOfSelectionInWindow:(NSWindow *)window {
    [[self textField] setEditable:YES];
    [[self textField] setSelectable:YES];
    // make textField (textView) first responder
    [[self textField] selectText:nil];
    [[[self textField] currentEditor] setSelectedRange:NSMakeRange([[[self textField] stringValue] length], 0)];      
}

Because I don’t want the NSTextFields to be editable when the row they are in isn’t selected, I also do this in my custom NSTextField subclass:

- (void)textDidEndEditing:(NSNotification *)notification {
    [self setEditable:NO];
    [self setSelectable:NO];
    [super textDidEndEditing:notification];
}

Selection update code: (note that I’m also changing row heights here)

- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row {
    // get the table veiw to animate/recalculate height of row
    NSMutableIndexSet *changedRows = [NSMutableIndexSet indexSet];
    [changedRows addIndex:row];
    [changedRows addIndex:[tableView selectedRow]];
    [tableView noteHeightOfRowsWithIndexesChanged:changedRows];
    [rowView notifyOfSelectionInWindow:[self window]]; 
    // ^ this in turn calls a method of the same name of the corresponding cell view
    return YES;
}

Problem is, this works only half of the time. The first time I try selecting a row, first responder status returns to the table view. The second time, it works perfectly, and the Text field has focus. The third time, it breaks again. The fourth – it’s perfect! For some strange reason, the code only works every other time…

Anyone have any idea why this is so? Any enlightening feedback is much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:43:04+00:00Added an answer on June 1, 2026 at 11:43 am

    When switching from from textField to textField in a tableView , events are called in what is an unexpected order (until you think about it).

    The problem here is the order that your delegate methods are being called.

    Let’s say that you are going from textField1 to textField2.

    Once textField1 is already active and you click on textField2, they get called like this:

    textShouldBeginEditing  (textField2)
    textShouldEndEditing    (textField1)
    textDidEndEditing       (textField1)
    textDidBeginEditing     (textField2)
    

    Because textShouldBeginEditing is called before textDidEndEditing (because it needs to make sure that it can select the row before it gives up its’ old one) you need to update your self.textField in textDidBeginEditing instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view which consists of a tableview and a navigation bar. For
I currently have a tableview with youtube videos embedded inside of the custom cells.
Currently I have the following method, but it doesn't quite work... - (UITableViewCell *)tableView:(UITableView
I have a UITableView, and currently it has a single cell in it. I
I have a tableview with UISwitch in each row of the table. Switch is
Currently, I have a table view that the user can add items and delete
I currently have a UIAlertview displaying a grouped table view and have spent all
I have ViewController (A) with TableView where each row is a directory name. Each
I have a table view which I'm using for some settings in my app.
In my iPhone app, In Table view I have Two labels in one cell..

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.