• 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: Setting Custom View as First Responder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting Custom View as First Responder


  • Subject: Re: Setting Custom View as First Responder
  • From: Rob Keniger <email@hidden>
  • Date: Sun, 18 Jan 2009 14:45:31 +1000


On 18/01/2009, at 2:13 PM, Walker Argendeli wrote:

I've created a custom view with 2 instances in the nib. We'll call them view1 and view2. I have a controller class that has the outlets for both views. I'd like to have a certain function in my controller class test to see if view1 is the first responder, and if not, to make it the first responder.
if (![[view1 window] firstResponder]
{
// Do something
}
How do I set a custom view to be the firstResponder?


NSView is a subclass of NSResponder so you have to override - acceptsFirstResponder and -becomeFirstResponder to return YES. In - becomeFirstResponder you implement code to indicate that your view is the first responder, such as changing the border color. You also should override -resignFirstResponder which will allow you to update your view to remove the changed appearance when your view is no longer the first responder.

--
Rob Keniger



_______________________________________________

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


References: 
 >Setting Custom View as First Responder (From: Walker Argendeli <email@hidden>)

  • Prev by Date: Re: Setting Custom View as First Responder
  • Next by Date: Re: Find bindings
  • Previous by thread: Re: Setting Custom View as First Responder
  • Next by thread: Find bindings
  • Index(es):
    • Date
    • Thread