I finally had a breakthrough!  I'm not sure it's the "best" solution but it 
works and hopefully will be instructive for others trying to do the same thing 
connection views.  There's a lot of steps (which is why I think it may not be 
the "best") so I'll try to be as clear as possible.

1) when a user clicks their mouse in my subclasses NSTextField I send this 
action:
 BOOL theResult = [NSApp sendAction:@selector(notifyViewOfMouseDown) to:nil 
from:nil];

2) my subclassed view has a method that executes when this action is sent:
- (void)notifyViewOfMouseDown {
        
        NSDictionary *d = [NSDictionary dictionaryWithObject:self 
forKey:@"view"];
        
        NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
        [nc postNotificationName:SRVIsSelectedChanged object:self userInfo:d];
        
}
This allows me to package up the view and send it along in a notification.  
Packaging the view is **key** here because this is the view that needs to be 
selected.  My subclassed NSCollectionView is registered as an observer of this 
notification.  When it receives this notification I execute this code to update 
the array controller with a new selectedObject

- (void)handleViewSelections:(NSNotification *)note {
                
        View *v = [[note userInfo] objectForKey:@"view"];
        
        
        int limit = [[self content] count];
        
        for (int i = 0; i < limit; i++) {
                NSCollectionViewItem *item = [self itemAtIndex:i];
                View *thisView = [item view];
                
                if ([thisView isEqual:v]) {
                        [item setSelected:YES]; //my subclassed 
NSCollectionViewItem knows how to set itself as selected and update the array 
controller
                }
        }
        
        
}


Boy, I'm glad I figured that out!  I'm sure there are a lot more experienced 
programmers than me out there so if anyone can think of a way I can do this 
without so many steps I'd be glad to learn from them.

Jonathan, thanks for your suggestion.  My subclassed NSTextField didn't respond 
to superview.  I wish it did, it would have saved me a step.  To adapt your 
solution I'd need to register each newly created view in my NSCollectionView 
link that back to the NSCollectionViewItem that has the code to set itself as 
selected and to update the array controller.  I had to delete your reply from 
this message to make it thru the listserve size 
limit._______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to