On 2012-08-10, at 7:30 PM, Andy Lee <ag...@mac.com> wrote: > If there's one specific control class that you want to detect focus for, you > can subclass it and override becomeFirstResponder. If super returns true, do > your thing. > > If you want to apply this to a bunch of varied controls, you might want to > use a subclass of NSWindow and override makeFirstResponder: (again, checking > what super returns). > > --Andy >
So I do have a handful of cases which I will want to swap in editing views for the display views. So I have a subclass of NSWindow with the following method: - (BOOL) makeFirstResponder:(NSResponder *)responder { if([super makeFirstResponder:responder]) { if([responder isEqualTo:[self.windowController displayField]]) { NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, @"call activateEditorView"); [self.windowController activateEditorView:self]; } return YES; } return NO; } The windowController has the following method: - (IBAction) activateEditorView: (id)sender { // self.displayField is the field which triggers this line of action if([self.displayField resignFirstResponder]) { NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, @"replaceSubView:with:"); [[self.window contentView] replaceSubview:self.displayView with:self.editorView]; [editorView setNeedsDisplay:YES]; } } Sadly, although the messages are logged the -replaceSubview:with: does not accomplish any change. Have I done (or not done) something foolish in here? I have tried moving firstResponder out of the displayField prior to the replaceSubview: call but without apparent effect on the replaceSubview: outcome (relocating the focus did happen). ~ Erik _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com