Re: Controller Selection Synchronization
Re: Controller Selection Synchronization
- Subject: Re: Controller Selection Synchronization
- From: Quincey Morris <email@hidden>
- Date: Sun, 10 Apr 2011 10:44:57 -0700
On Apr 10, 2011, at 07:56, Richard Somers wrote:
> The primary view is a custom view that displays objects spatially according to their position in x, y, z coordinate space. The secondary views are table type views.
> I currently have a transient selection property for each object in the data model which helps in restoring the selection when undoing an object delete. The primary controller (for the custom primary view) is a custom programatic subclass of NSArrayController that synchronizes the primary controller selection with the transient selection property.
>
> The secondary controllers (NSArrayController and NSObjectController) and secondary views (table views) are all standard Interface Builder objects.
>
> The problem is how to synchronizing the selection among all the various controllers.
In the primary views, objects can get their selection status the same way they get (for example) their xyz position, whatever that is. For example, view objects could be KVO observers of their data model properties, or the custom view could do this on their behalf, or something could be pushing property value updates out to the UI objects.
For the other views, I'd suggest making 2 selectionIndexes properties (assuming NSTableView -- outline views are slightly different) in the window controller, and binding the array controllers to these properties. Whatever mechanism is getting selection status to your primary view objects should also maintain these 2 properties, KVO compliantly of course. The last piece would be to use the table view delegate method to push changes of selection in the table to your main view. (That would apparently send you round in a loop updating the 2 properties, so you'd probably want to check whether the 2 properties really need updating before doing it, rather than relying on the frameworks doing nothing if you set the selectionIndexes properties to the current selection indexes.) Or, you could observe the properties instead of using the delegate method.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden