• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa and 10.1.2 [two bugs solved]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Cross platform Cocoa/Obj-C
  • Next by Date: Saving/Opening Files - different under PB than with build of app
  • Previous by thread: Opening Files in Doc-based App
  • Next by thread: Saving/Opening Files - different under PB than with build of app
  • Index(es):
    • Date
    • Thread