• 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: NewbieQ: Why can't I have a customview as an initalResponder??
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NewbieQ: Why can't I have a customview as an initalResponder??


  • Subject: Re: NewbieQ: Why can't I have a customview as an initalResponder??
  • From: Andrew Platzer <email@hidden>
  • Date: Mon, 21 Jan 2002 13:30:52 -0800

On Saturday, January 19, 2002, at 08:13 , email@hidden wrote:
Newbie here. I want to have a custom view be the initial responder in a simple window, but I can't make it work. As a test, I created a window in IB with just a custom view, and then set the Window's initialFirstResponder outlet to the CustomView (after setting the customview's class to my custom view). But the @#$@#% custom view does not come up as the first responder.

If I throw a textfield onto the window, IT becomes the initalResponder, even though IB says that my custom view is the first responder.

My custom view does nothing but paint it self red when its NOT the responder, and green when it is. When the window opens the view comes up red, until I click on it, and then it turns green.

I have NSLog messages that show that the CustomView receives an acceptsFirstResponder message (which it answers YES), but it never gets a becomeFirstResponder message until I click on it.

The test code is tiny and is attached to the bottom of this message. Is there some law against custom views being the first responder or am I just missing some magic cocoa beans??

By default, unless you have full keyboard UI turned on, only controls like NSTextField and NSBrowser can accept first responder status. That's why it jumps to a text field on loading the nib. If your control is similar in that it always wants to accept key focus, override the method -[NSView needsPanelToBecomeKey] to return YES.

This method is poorly named (historical reasons) and we are looking at making it a bit more obvious what to override to get the behaviour you want and adding to the documentation.

Andrew
__________________________________________________________________
A n d r e w P l a t z e r
A p p l i c a t i o n F r a m e w o r k s
A p p l e


  • Follow-Ups:
    • Re: NewbieQ: Why can't I have a customview as an initalResponder??
      • From: email@hidden
    • Re: NewbieQ: Why can't I have a customview as an initalResponder??
      • From: otto <email@hidden>
References: 
 >NewbieQ: Why can't I have a customview as an initalResponder?? (From: email@hidden)

  • Prev by Date: Re: NSSplitView size, how to change ?!
  • Next by Date: Re: Centering a view in an NSScrollView
  • Previous by thread: NewbieQ: Why can't I have a customview as an initalResponder??
  • Next by thread: Re: NewbieQ: Why can't I have a customview as an initalResponder??
  • Index(es):
    • Date
    • Thread