Hi all,

I have an NSCollectionView in whose item-views I want to do some event handling (validateMenuItem: to enable / disable the events that currently make sense and a bit of keyboard / mouse input), but I'd also like the NSCollectionView to handle the selection of items. So I pass the mouseDown event to [super mouseDown] so that it eventually reaches the NSCollectionView so it can handle updating the selection. This makes the item-view lose firstResponder and my event handling ambitions are foiled. Now, I make the item-view firstResponder again in its "setSelected" setter (which is bound to the representedItem.selected property, so it gets called after the NSCollectionView handles the selection). Unfortunately, if I add a new item to the NSCollectionView (via its NSArrayController), I once again lose first responder* and I have no idea how to regain it, so my event handling / keyboard shortcuts work properly again...

* backtrace for who causes my item-view to lose firstResponder:
#1  0x95f9a355 in -[NSWindow makeFirstResponder:] ()
#2  0x964e4625 in _NSDiscardEditingForView ()
#3  0x9657ea69 in -[NSCollectionView _contentChanged:regenerate:] ()
#4  0x9657b2c5 in -[NSCollectionView setContent:] ()
#5  0x965651b2 in -[NSCollectionViewBinder _updateContent] ()
#6 0x96565260 in -[NSCollectionViewBinder _observeValueForKeyPath:ofObject:context:] ()
#7  0x93b9358e in NSKVONotify ()
#8 0x93b23e45 in -[NSObject(NSKeyValueObservingPrivate) _notifyObserversForKeyPath:change:] ()
#9  0x95e9e15e in -[NSController _notifyObserversForKeyPath:change:] ()
#10 0x95e9e05f in -[NSController didChangeValueForKey:] ()
#11 0x960b9e88 in -[NSArrayController didChangeValuesForArrangedKeys:objectKeys:indexKeys:] () #12 0x960b9999 in -[NSArrayController _insertObject:atArrangedObjectIndex:objectHandler:] () #13 0x960b96e2 in -[NSArrayController insertObject:atArrangedObjectIndex:] ()
#14 0x960b9406 in -[NSArrayController addObject:] ()

The new firstResponder after the above "incident" is my main window. :(

Any insight? Or is there a different way of handling things?


Thanks,
        Daniel.
_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to