Re: NSView subclass does not seem to start
Re: NSView subclass does not seem to start
- Subject: Re: NSView subclass does not seem to start
- From: Ken Thomases <email@hidden>
- Date: Mon, 30 Dec 2013 17:05:04 -0600
Hi,
On Dec 30, 2013, at 4:34 PM, Alex Hall wrote:
> Anyway, the problem remains that I need to capture keystrokes (and eventually mouse movements) in a subclass of NSView, but nothing seems to happen.
In order for a view to receive key events, it must be the first responder. Typically, you need to override -acceptsFirstResponder to return YES to allow a view to become the first responder. (There are other approaches, but that's the normal one.)
After that, you either want to set the window's initialFirstResponder to be that view before the window is shown or you want to call -[NSWindow makeFirstResponder:] to set the first responder at a later time.
Cheers,
Ken
_______________________________________________
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