Extended NSTableView - objective-c

I would like to make a table-view with expanding ability.
When you press a row, the row should expand to show options like delete, copy and so on.
I have found an example for iOS, but I didn't get it running on Mac OS X, because NSTableView and UITableView are very different.
http://www.cocoacontrols.com/platforms/ios/controls/kofiles
Has anyone another template?
Or maybe even get this example running on Mac OS X?

I don't have code to hand you but you can use a view-based NSTableView. Your prototype view can resize itself to include controls if it's selected. All that's a bit complex to condense into a reasonably brief answer but if you use a view-based table view and treat the prototype view like any other that would grow and show extra controls, then wire this behavior to the selection state, it should work.
Note: you will have to write some code for the expansion portion, to handle resizing it, showing the controls, and notifying the table view that one of its rows changed height. Lots of documentation and examples exist out there for each individual component of your problem. Post more specific questions as you run into roadblocks.

Related

Prevent NSOutlineView (or NSTableView) from redrawing on scroll

It seems that my view-based OutlineView try to re-render text every time user scrolling. I think that was because it tried to save memory by re-using rows that fall outside of visible rectangle, then re-render new data to those old views. How can I disable this? I'm willing to sacrifice memory to archive this so that I can get better scrolling performance. (I have tried with various optimize like layer or so, but no luck).
EDIT: There is another question with same purpose as mine here How to make NSTableView not reuse TableCellViews, but no answer yet :(
I think you are confused -- it doesn't re-render the text. The table only shows views for the visible area (caveat below), and pulls in new views as you scroll -- potentially re-using old views.
You provide the view. Use the delegate method viewForTableColumn:row: and return your own cached view for a given row.
But that isn't going to prevent drawing; the view will likely still get marked dirty and draw.
I don't think you are asking the right question. It sounds like you have a performance problem. To help you with that, we'd have to see samples or instrument traces.
Caveat: Responsive Scrolling will pull in views that are in the non visible area. See the AppKit release notes about this.
corbin

Window doesn't render as expected, controls gets messed up

I have a NSWindow with autolayout, There is one view based NSTableView with few controls like images and labels . Once in a while the window comes ugly, means all the constraints doesn't work, and the text fields, images just loose their places.
All the controls inside the tableView are seen in (0,0). But only for few rows, for other rows it work perfectly, however all rows contains same controls.
This is happening only for the first time specially in OSX 10.10 when installing from DMG, if I reopen the window again then every thing look OK, no overlapping of text and other controls.
Please help to understand the issue, or any suggestion to fix.

UTextView autocomplete vs live suggestions iOS

If I turn the autocorrection ON, the words get autocompleted, as if I write "wor", I get "word" before I finish writing. I don't want this to happen because I might be writing "world" or any word different than the autocompleted one.
I set Correction off in the Interface Builder and this problem is solved.
The problem now is that I still need the suggestions that appear in a little popover below the incomplete words.
This two features might be different but I don't know how to activate the suggestions.
How can I solve this?
This can be solved with the use of tableview. Create a tableview with the width as of the width of the textfield and height as you like. Place it just below the textfield. Make it hidden initially. When the user starts typing, fetch the array of data that resembles to the typed text and if any exists then, unhide the table view. On the subsequent typing keep on reloading the tableview sections with animations. You should be accurate on hiding, unhiding and then reloading the data on the tableview. I have implemented such thing before. It is really easy and once you get started with it you find it easy.
In the UITextView TextViewDidChange I created a thread that changed the cursor position. This, off course happens after the text view changes. The change of the cursor position triggers the autocomplete without letting me even see that there had been a suggestion.

Which control can be used in order to display a dynamic form (with various types of data)?

I'm facing the following problems:
We have meta data for items, each item can be a different type of NSControl, currently NSTokenField and NSTextField, but we might need NSCombo or other types.
I need to build a form in which each entry will have a label and an editable control.
this form has to be built dynamically since the items are retrieved from the server.
I've implemented it with NSMatrix, and apart from it looking pretty shabby, I'm faced with some visual issues I don't know how to solve.
The visual issue is every time I move the mouse over the NSTextFieldCell the tokens get drawn on the top left corner of the NSMatrix form.
now, I'm considering moving to another type of control,
I've googled for few hours, and found the following controls:
NSForm,
NSMatirx (parent of NSForm),
NSCollectionView,
NSTableView
which one of these is the most appropriate for this task?
I hope I am clear since I wanted to add pictures, but it wouldn't let me due to lack of "reputation points".
Thanks for your help,
Eyal.
NSTokenField is a subclass of NSTextField so you could use an NSTableView to display them.
You could also draw a custom NSCell with all elements in it. When each "item" has a different number of elements then this becomes a bit more complicated though.

Cocoa one row table view or a horizontal list view

Is it posible to use table view to show just one row of a big amount of elements? What I'm looking for is for some kind of horizontal list, like we have in XCode preferences or Aperture image list.
It would behave just like a one columnt table view, but instead of showing the elements vertically, it should be horizontally.
Can you point me to where should I start from?
If you're okay with Leopard-only, The new NSCollectionView supports horizontal display. Just set the collection view's number of rows to 1 in Interface Builder; it'll even handle the horizontal scroll bar for you. The IconCollection sample code provides a simple demonstration of how it works. It's bindings work similarly to a table view's, except instead of rows and columns, each object represented gets an 'item' (an object of type NSCollectionViewItem) that displays it, and those items will be laid out in a grid. The sample code above demonstrates how to set up these 'items' in Interface Builder, which is definitely the easiest way.
With a table view? No. If I'm understanding correctly what you want, in the past I've created my own NSView subclass for this type of control. Define a data source protocol similar to NSTableView, and in your NSView drawRect method, draw the elements in order one by one from left to right. You can either keep track of paging in your control, or put it in a scroll view and resize yourself whenever the number of items changes.
Usually this type of thing starts off pretty simple, and gets a bit complex once you start handling caching, paging, selection, mouse and keyboard input and so on. My advice, start as simple as possible and add new features one by one, only after you've finished the previous task.