Re: Set up an editable view based NSTableView programmatically - how to?
Re: Set up an editable view based NSTableView programmatically - how to?
- Subject: Re: Set up an editable view based NSTableView programmatically - how to?
- From: Seth Willits <email@hidden>
- Date: Tue, 07 Jan 2014 16:47:01 -0800
To clarify: this isn't mixing approaches. Willeke isn't using any datasource methods at all.
tableView:viewForTableColumn:row: is a delegate method. The *only* datasource method view-based table views support is the objectValue getter, which simply sets the objectValue property on the view returned by the delegate method, if that view has one. That's it. It's the same as assigning tableCellView.objectValue in that delegate method yourself.
--
Seth Willits
On Jan 7, 2014, at 4:17 PM, Peter <email@hidden> wrote:
> Great! Yes, this helps immensely. Thank you very much!
>
> It didn’t occur to me that it is possible to mix the bindings and data source approaches.
>
> In order not to waste more time and get my job done, I took resort to a double click method copying the data to be edited to an NSTextField, whose action methods feeds the edited value back into the data source. Works very nicely and fits my bill even better than inline editing.
>
> Still, your proof of concept is extremely useful!
>
> Am 08.01.2014 um 01:01 schrieb Willeke <email@hidden>:
>
>>
>> Op 7 jan 2014, om 16:52 heeft Peter het volgende geschreven:
>>
>>> I’d actually prefer to use bindings, but my first column should simply display the row numbers
>>
>> After some experimenting I managed to create a simple editable view based table view with row numbers, using bindings except for the row number. The row number is in a column with identifier "RowNumber". I implemented this delegate method:
>>
>> - (NSView *)tableView:(NSTableView *)tableView
>> viewForTableColumn:(NSTableColumn *)tableColumn
>> row:(NSInteger)row
>> {
>> NSTableCellView *result = [tableView makeViewWithIdentifier:[tableColumn identifier] owner:self];
>> if ([[tableColumn identifier] isEqualToString:@"RowNumber"])
>> result.textField.objectValue = [NSNumber numberWithInteger:row];
>> return result;
>> }
_______________________________________________
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