I have a subclass of NSOutlineView that implements copy:, paste:, cut: etc.
Also, the NSDocument subclass implements these same methods.
When the outline view is in the responder chain (is first responder or a parent view of it), all copy/paste events are intercepted by the NSOutlineView subclass. What I want, is depending on the context catch some of these messages, or let them propagate and be caught by the NSDocument subclass.
What I want is basically:
- (void)copy:(id)sender
{
// If copy paste is enabled
if ([self isCopyPasteEnabled]) {
[[NSPasteboard generalPasteboard] clearContents];
[[NSPasteboard generalPasteboard] writeObjects:self.selectedItems];
return;
}
// If copy paste is disabled
// ... forward copy: message to the next responder,
// up to the NSDocument or whatever
}
I've already tried many tricks, none was successful:
[[self nextResponder] copy:sender]that doesn't work because the next responder may not implementcopy:[super copy:sender]same here, super doesn't implementcopy:[NSApp sendAction:anAction to:nil from:sender]this is nice to send an action to the first responder. If used inside an action
Sure I could manually loop on the responder chain until I find something that responds to copy: or even directly call copy: on the current document, but I'm looking for the right way of doing it.
Many thanks in advance!