Re: No mouseExited when switching windows
Re: No mouseExited when switching windows
- Subject: Re: No mouseExited when switching windows
- From: Steve Mills <email@hidden>
- Date: Tue, 19 Feb 2013 11:16:20 -0600
On Feb 18, 2013, at 16:46:10, Fritz Anderson <email@hidden> wrote:
> "Notified" is the right word. NSWindow posts NSWindowDidResignKeyNotification and NSWindowDidResignMainNotification. There are also delegate methods with nearly the same names (which get passed the same notification objects).
Ah, thanks. I've added this, but it's not behaving nicely. I have a NSControl subclass (FCBaselineView) that is NOT loaded from a nib, but instantiated manually and added to its owning superview. I've overridden viewWillMoveToWindow in my subclass so I can add the notification observer at a time when the window exists:
-(void) viewWillMoveToWindow:(NSWindow*)newWindow;
{
// Does the super need to be called? I kind of assume it does not from the docs, but it's not clear.
[super viewWillMoveToWindow:newWindow];
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
[center removeObserver:self name:NSWindowDidResignKeyNotification object:nil];
[center addObserver:self selector:@selector(windowDidResignKey) name:NSWindowDidResignKeyNotification object:newWindow];
}
Then implemented the windowDidResignKey method:
-(void) windowDidResignKey:(NSNotification*)notification
{
UNUSED_VAR(notification);
printf("notify\n");
}
When I switch windows, I get an exception thrown:
2013-02-19 11:11:10.330 app[40530:303] -[FCBaselineView windowDidResignKey]: unrecognized selector sent to instance 0x11f6b750
2013-02-19 11:11:10.331 app[40530:303] -[FCBaselineView windowDidResignKey]: unrecognized selector sent to instance 0x11f6b750
2013-02-19 11:11:10.339 app[40530:303] (
0 CoreFoundation 0x92b9c12b __raiseError + 219
1 libobjc.A.dylib 0x9854852e objc_exception_throw + 230
2 CoreFoundation 0x92b9fd9d -[NSObject(NSObject) doesNotRecognizeSelector:] + 253
3 CoreFoundation 0x92ae8437 ___forwarding___ + 487
4 CoreFoundation 0x92ae81e2 _CF_forwarding_prep_0 + 50
5 Foundation 0x97845c52 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 49
6 CoreFoundation 0x92b5de01 ___CFXNotificationPost_block_invoke_0 + 257
7 CoreFoundation 0x92aa943a _CFXNotificationPost + 2794
8 Foundation 0x9782e788 -[NSNotificationCenter postNotificationName:object:userInfo:] + 92
9 Foundation 0x9783e527 -[NSNotificationCenter postNotificationName:object:] + 55
10 AppKit 0x93c87143 -[NSWindow resignKeyWindow] + 599
11 AppKit 0x93b1021d _NXSendWindowNotification + 60
12 AppKit 0x93950c0b endKeyAndMain + 81
13 AppKit 0x93b3768c -[NSApplication sendEvent:] + 3379
14 AppKit 0x93a5172c -[NSApplication run] + 951
15 AppKit 0x939f46f6 NSApplicationMain + 1053
16 app 0x012d2c30 main + 160
17 app 0x00002d65 start + 53
18 ??? 0x00000003 0x0 + 3
)
--
Steve Mills
office: 952-818-3871
home: 952-401-6255
cell: 612-803-6157
_______________________________________________
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