Note that there are some explanatory texts on larger screens.

plurals
  1. PONSTableView no selection highlight, but keep track of what row is selected
    primarykey
    data
    text
    <p>I've seen some threads with a similar question to this (not exactly the same) but the solutions there didn't solve my problem. I've create a NSTableView with a couple clickable elements in each TableCellView -- a TextField, a DatePicker and a Button -- and I need to be able to click into each of these without first selecting the row they are in. I achieved this by using <code>setSelectionHighlightStyle: NSTableViewSelectionHighlightStyleNone</code> However, I still need to know the index of the row that is being edited, because I need to pass the edits into a model object associated with each row. I tried writing the following, which was the suggestion of some of the other threads I mentioned, but it didn't do anything.</p> <pre><code>- (BOOL)tableView:(NSTableView *)tableView shouldTrackCell:(NSCell *)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{ return YES; } </code></pre> <p>I'm not 100% sure if that's the wrong method to use for this, or if I'm just implementing it incorrectly. Any tips on how I could go about this would be awesome.</p> <hr> <p><strong>Edit:</strong></p> <p>Here's my attempt at implementing Steve Waddicor's suggestions:</p> <p>Making the ViewController the NSTableViewDataSource and set the TableCellView as the delegates for the objects (code is in MyViewController.m):</p> <pre><code>- (void)awakeFromNib{ [self.tableView setDataSource:self]; } - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { CustomTableCellView *view = [self.tableView makeViewWithIdentifier:@"MyIdentifier" owner:self]; [view.textField setDelegate:view]; [view.datePicker setDelegate:view]; return view; } //----------------------- //----------------------- //----------------------- NSTableViewDataSource Protocol Requirements: - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView { return [self.tableView numberOfRows]; } - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { return [self.tableView rowViewAtRow:rowIndex makeIfNecessary:NO]; } </code></pre> <p>and in CustomTableCellView, this is the delegate method which isn't being called when I click on the TextField, which leads me to believe that the delegates aren't being set for the objects correctly:</p> <pre><code>- (void)mouseDown:(NSEvent*) theEvent{ NSLog(@"TEST"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload