OK, this is my situation :
I have an NSMutableArray bound to an NSTableView, via an NSArrayController.
I'm manipulating the table view's selection (trigger by keyboard), using NSArrayController's selectNext: and selectPrevious:
The thing is : The selection does change, but the table view doesn't scroll to the current selection, so that its content is visible.
What should I do? Any ideas?
There is a method in NSTableView
- (void)scrollRowToVisible:(NSInteger)row;
That will scroll to the specified row.
Related
This has been befuddling me for hours...
I have an object (CuesDoc) with a property (NSMutableArray *cuesArray) and some other properties. The cues array holds multiple Cue objects. There is a property called (CuesDoc*) currentCuesDoc in my AppDelegate.
In IB, I have an NSArrayController, which is bound to the AppDelegate.currentCuesDoc.cuesArray.
I have a view-based NSTableView which is bound to the NSArrayController and can add/remove/edit values in the table and cuesArray. So far so good.
I have detail fields below that, which are bound to NSArrayController.selection, with the model key path set to each property.
When the view first appears, the detail fields populate with the contents of the first item in the table view, however when I select other rows, the detail fields do not update to reflect the current selection.
I added an observer to selectionIndexes and selection for the NSArrayController, and when the view appears, I get called for the observeValueForKeyPath: method once, but not after changing selections.
For view-based NSTableViews, you must bind the tableView's selection indexes to the array controller key of selectionIndexes to keep the view's selection in sync with the controller's selection. Selection bindings are separate from content bindings. The older, cell-based NSTableView APIs did not require this step.
I have a view-based NSTableView for which some cells have enough content that it doesn't fit. I would like to be able to have the cell automatically expand when a user hovers their cursor over the cell.
In searching for this, it seems that this is the default behavior for a cell-based NSTableView. There are even methods like shouldShowCellExpansionForTableColumn, which the doc says is for cell-based table views only. Somewhere else in the doc implies that this expansion behavior is even on by default for cell-based table views?
- (BOOL)tableView:(NSTableView *)tableView shouldShowCellExpansionForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
I get the impression that I'm missing something obvious.
Goal:
Be able to put multiple rows of NSTextField objects in a view-based cell (more than there is pace to handle)
If the content overflows, put a visual indicator into the cell
When the user does a tool-tip style hover on the cell, expand the view to show all the content
You seem to be on the right track as this should work for cell based NSTableViews. You need to put tableView:shouldShowCellExpansionForTableColumn:row: in the tableView's delegate. You could reply YES for the column of interest.
With a view based table where you use NSTextFields these scroll, truncate or wrap but there is not an expand on hover option. It is possible to set the tooltip text to be the same as the content which might be a reasonable solution.
Did you try to change the row height (tableView:heightOfRow:) triggered by some mouse action? You might have to reload the tableview.
I have a UITableView that I populate with cells in the normal fashion using the datasource and delegate. I would like to add a custom subview, that does the following:
1) scrolls with the UITableView
2) is seen beneath the UITableView scrollbar
3) can be moved and animated independently of any cell (acts as a selector that animates from one cell to the next)
I know how to animate a selector over the top of the UITableView, but that violates requirement #2 (it makes the scrollbar look terrible)
Has anyone seen an implementation of this, or know the proper way of doing it?
Did you try something like this?
Have a base view.
Add your custom subview to the base view.
Then add your table view on top of it to the base view.
Implement the table's scroll delegates and move the custom subview.
Thinking at the top of my head, couldn't you disable the scrollbar for the table view and place a transparent scroll view with the same dimension as the table view on top. You're effectively using the scroll bar of the scroll view instead of the table view. You'd scroll the scroll view in step with the table view.
I have an NSTableView bound to an NSArrayController which fetches some entries from core data.
I would like to have a custom view cell in the bottom of that NSTableView so that when the user scrolls to the last element in the table, a scrolling indicator will appear instead of a table view cell.
This is similar to what happens in the twitter for mac application, where you scroll to the bottom of the list to fetch more results.
Because the binding is done in the nibs, I'm not quite sure if I need to change that and set the NSTableView datasource to my windowcontroller and increase the number of rows with 1.
Is there a simple way to do this?
I have dragged an item into my tableview object.
When the dragged item hover over an item in tableview,
the item is redrawn with selection background. The image is as under
The row of the tableview is not selected, when i checked selectedRow method.
My requirement is when an item hover any item i should control its selection
and the background selection thereof.
Thanks,
iSight
To 'control' the selection of a TableViewCell when 'hovering' over such an item you will have to call this method:
- (NSIndexPath *)indexPathForRowAtPoint:(CGPoint)point
It's a method from the UITableView Class and uses the local coordinate system of your tableView. As is mentioned in the Apple Doc: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableView_Class/Reference/Reference.html
When the method is called you will have a NSIndexPath returned. With it you can select the cell/item at that particular path.
Mind, selecting a path manually doesn't call the didSelectRowAtIndexPath delegate-method so if you want a certain method called from that delegate you will have to do that manually as well!
This method is prolly called from the touchedDidMove method (where you also do the drag&drop) so getting the point needed for the method shouldn't be a problem for you.
You will figure it out :)
Good luck.