Is there a reasonable way to handle or override a view in an NSScrollView?

Background:

I am creating a view-based NSTableView-esque control in Cocoa / Objective-C that makes it easy to use a UITableView in terms of the ability to layout a view in Interface Builder and not a subclass of NSCell. Its also smart with its resources, as it adopts a similar reusable cellular paradigm such as a UITableView. This, of course, is all done inside NSScrollView.

I have most of the complex exchange of opinions, understood and working. When scrolling, if the view is fully cropped, it is added to the pool of unused views. Similarly, if a non-displayable view falls within scope, it tries to grab the view from an unused pool, and if none of them are available, it creates a new one from nib containing the prototype of the view.

Similar solutions exist there, but I like to mess around and I implement it myself :). However, I do not know the solution that handles this problem, and I need some advice!

Problem:

Say, for example, that each view contains a text field. If the text field is edited and the user starts scrolling, I would like this cell not to be released into the pool, so that it does not "lose focus" or "give focus" to the newly displayed view that reuses the released one. Is there any reasonable way to mark a view as edited without requiring the programmer who created a custom view to intercept events and mark it as such?

Thanks for the help!

+4
source share
1 answer

Your view controller may conform to the unofficial protocol NSEditorRegistration . It is designed to solve this particular problem.

+2
source

All Articles