NSTableView as a form - nextKeyView issue (or how to force load all rows) - macos

Perhaps using an NSTableView as a form is a terrible idea, but I've got it working pretty well in every respect except that you can't tab from field to field.
I have a table with a label column and a field column. I also have an array that keeps track of each row in the table with its accompanying NSTextField control. The controls are set in the array as they are loaded during tableView(tableView: viewForTableColumn: row:).
After the tableview is drawn, I run through each control in the array and set its nextKeyView to the following control.
This works swell, BUT only for those controls which have been displayed on screen. Because the control isn't added until it's loaded, table rows which are off-screen aren't hooked up.
My current approach (which is awful) is to manually scroll the table several times in order to force everything to load, then set all the nextKeyViews. I haven't got it working very well yet, so I was hoping someone had a better idea. Force-loading all views, if it works, should be an OK solution, but there may be something smarter out there too.

I guess the answer is
table.scrollRowToVisible(<row>)
This will show the row you want to see.

Related

View based NSTableView having Sluggish Scrolling

I am using View based NSTableView where I have around 30 columns and rows could be in between 200 - 1000. The problem is that the tableView is very sluggish. After doing some debugging, I figured out that adding an identifier to NSTableCellView made the scrolling super fast. But the problem arose that no data was displayed. Since all the data being displayed to the columns is using binding, so no code has been written for it. Now, I am not able to figure it out why is that happening or what is the correct way of using view based NSTableView using binding and reusing Cells. Could someone provide me some highlights on how to make the scrolling smooth for such scenarios.

Single cell selection NSTableView

There are a few google results for this question but they are ancient and didn't really help. So I'm asking again for modern uses, how can I set up selection for a single row and column. Like the Numbers app. So the row/column its self is not highlighted but the focus ring is drawn for the row, column that was selected.
I'm open to Cell based or View based implementation. I have tried doing things inside the
- (void)tableViewSelectionDidChange:(NSNotification *)notification
but haven't been able to get things working or looking nice.
Has anyone done this, is there a better view architecture for this?

How to correctly add NSComboBox to view-based NSTableView in Interface Builder

I'm basically asking how do you correctly add a Combo Box to a Table View with correct layout i.e. so that appears as if you were adding a ComboBox cell to a cell-based Table View. Currently when I add it to the Table Cell View it doesn't fit (bottom half chopped off) and doesn't behave as its supposed i.e. focus ring is messed up, arrows messed up, not aligned correctly.
I have searched the net couple of times over and funny enough I haven't found an answer to this question. If I don't find a solution I might have return to good old cell-based table views.
If the combo box doesn't fit, you need to increase the height of the NSTableCellView. This is done in Interface Builder or, if implemented, in the NSTableViewDelegate method tableView:heightOfRow:.

How do I reset a table view?

I have a table view in an iPhone xcode tab bar application that shows data either alphabetically or numerically, depending on a user selected option in one of the tabs. It works for the most part, but when I change the option and then go back into the table view, the table view initially looks like it did before the option was changed. However, as new cells get scrolled into view, they have the new display mode.
I can identify when the option changes, but I can't seem to get the code correct that would re-initialize the cells such that the next time they come into view they have the correct values. The data comes from a static array with set values, so I don't want to do anything with the data source, just the table view.
In other words, once the display option changes, I want to wipe out the table view I have so that the next time the table view displays it will show the correct data right from the start rather than after scrolling occurs.
Any help would be appreciated. Thanks.
It sounds like you want to call reloadData on the TableView.
[yourTableView reloadData];

scrolling a readonly cell in NSTableview?

I have a table that the user should not be able to edit directly (although user actions may cause changes). One column may contain a string too long for any reasonable size cell, so to see everything there, the user needs to scroll the cell (using arrow keys, for example).
If I make either the column or cell not editible, I loose the ability to scroll the cell.
If I make it editable, of course, I loose the ability to keep the user from changeing it.
(I'm using NSArray controller and a couple of NSObject controllers to get from the model to the table view using bindings. Binding compliance via #property(copy) and #synthesize. Updating the model with setXXXX:xxx).
Thanks,
John Velman
What's wrong with letting the table display tooltips for overflowed contents? This is automatic as of 10.5 if I recall correctly, else you can use the delegate method -tableView:toolTipForCell:rect:tableColumn:row:mouseLocation: for better control.

Resources