Re: Cocoa and 10.1.2 [two bugs solved]
Re: Cocoa and 10.1.2 [two bugs solved]
- Subject: Re: Cocoa and 10.1.2 [two bugs solved]
- From: Steve Gehrman <email@hidden>
- Date: Sat, 22 Dec 2001 17:51:01 -0800
Here's two bugs that Cocoa should handle internally.
1) When your view receives a mouseDown and the application is not
active. The mouseDown will not cause your view to become first
responder. It does work when the application is the front most and you
click in your view. This is inconsistent. My view returns YES for
acceptsFirstMouse.
So I had to add this code....
- (void)mouseDown:(NSEvent *)event
{
[super mouseDown:event];
// force a mouseDown to always set first responder even if the mouseDown
activates the application
if ([self window] && ((NSResponder *) self) != [[self window]
firstResponder])
[[self window] makeFirstResponder:self];
}
2) When you remove a view from it's superview, you must check to see if
it's the first responder and if it is, set the first responder to nil.
Otherwise the window points to a deleted view and you bomb. Cocoa
should do this automatically.
if (view == [[view window] firstResponder])
[[view window] makeFirstResponder:nil];
[view removeFromSuperview];
I guess neither of these related to 10.1.2, they have existed since the
beginning. These problems were causing my application to crash, but
only when the mouseDown also activated the application.
-steve