Re: Reordered columns and [tableView editColumn:0 row:ind withEvent:nil select:YES];
Re: Reordered columns and [tableView editColumn:0 row:ind withEvent:nil select:YES];
- Subject: Re: Reordered columns and [tableView editColumn:0 row:ind withEvent:nil select:YES];
- From: Graham Cox <email@hidden>
- Date: Thu, 8 Apr 2010 11:53:26 +1000
On 08/04/2010, at 11:46 AM, Chris Idou wrote:
>
>
> I've got some code that uses editColumn:0 to force the user into edit mode on the first column.
>
> But I've noticed that if user column reordering is allowed, this no longer edits the correct column. This seems odd to me because I thought Cocoa pretty much shielded the programmer from all the user reordering stuff.
>
> Even more oddly, if the user puts a checkbox as the first column, the checkbox seems to start behaving like a text box, albeit with invisible characters. Could I be doing something wrong, or is this some kind of bug? And do I have to somehow translate column 0 to find out the real column? I know Java tables have methods to translate between model and view column numbers because of user reordering, but I haven't noticed such a thing in Cocoa.
Yes, you're doing something wrong. You are assuming that column 0 is always a specific column, which because of user reordering, is not the case.
Instead of hard-coding 0 as the index of the column, look up its index by [NSTableView columnWithIdentifier:@"foo"]; The identifier is what identifies the column, not its index, so you have to look up the index dynamically.
--Graham
_______________________________________________
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