• 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: Problems with firstResponder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with firstResponder


  • Subject: Re: Problems with firstResponder
  • From: Ron Fleckner <email@hidden>
  • Date: Thu, 01 Sep 2011 12:32:34 +1000

Hello Geert,

I'm certainly no expert.  However, I've noticed that people learning Cocoa (and/or OOP) often directly set things that in fact don't need setting at all.  A lot of the basic functionality of Cocoa based apps comes for free.  Things like the responder chain usually do the right thing with very little input from the programmer.  This is no answer to your question, of course, but I suspect there may be something you've done that breaks the desired behaviour.  I've just spent literally about 30 seconds creating a test app with one window and six text fields.  Build and run and the first text field has firstResponder status -- that is, the text cursor is live and blinking inside it.  Pressing Tab moves firstResponder status to each other text field in turn and eventually comes back to the first.  Not a line of my own code.

So I guess the best thing for you to do is read the documentation and take some time to learn the system before beginning to modify it.  Or perhaps someone else with more intimate knowledge will help you.

Ron

PS NSApp is a global for your app, so [NSApp delegate] will get you a reference to your FakturaAppDelegate  instance.

On 01/09/2011, at 7:51 AM, Geert-Jan Korsbø Nilsen wrote:

> Thanks, Ron, I did put in the following code instead of becomeFirstResponder:
>
> FakturaAppDelegate *appDelegate = (FakturaAppDelegate *)[[NSApplication sharedApplication] delegate];
> [appDelegate.window makeFirstResponder:self.invoiceCredit];
>
> Now nothing works...
>
>
> On Aug 31, 2011, at 11:22 PM, Ron Fleckner wrote:
>
>>
>> On 01/09/2011, at 7:05 AM, Geert-Jan Korsbø Nilsen wrote:
>>
>>> Im working on a tiny app just to learn cocoa, and Im having a hard time with setting FirstResponder to some NSTextFields.
>>>
>>> When the view opens, I want the first NSTextField, clientNumber, to be selected, so I trigger [clientNumber becomeFirstResponder] at the end of my loadView method, but it does not select the text field.
>>> But when I click the button that fires the (IBAction)addToArray method, it selects the right text field. Further do I have another text field, it should contain integers only, so I have a crude verification for it. When the content is not a int, I get a beep, just like it should, but it does not select the text field.
>>
>> Geert,
>>
>> here's an excerpt from the documentation.  Note the last sentence.
>>
>>
>>
>> - (BOOL)becomeFirstResponder
>> Return Value
>> Returns YES.
>>
>> Discussion
>> If the previous first responder was not an NSTextView on the same NSLayoutManager as the receivingNSTextView, this method draws the selection and updates the insertion point if necessary.
>>
>> Use the NSWindow method makeFirstResponder:, not this method, to make a text view the first responder. Never invoke this method directly.
>
> _______________________________________________
>
> 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

_______________________________________________

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: 
 >Problems with firstResponder (From: Geert-Jan Korsbø Nilsen <email@hidden>)
 >Re: Problems with firstResponder (From: Ron Fleckner <email@hidden>)
 >Re: Problems with firstResponder (From: Geert-Jan Korsbø Nilsen <email@hidden>)

  • Prev by Date: Re: setTitleWithMnemonic
  • Next by Date: Re: Linking an NSWindow in IB
  • Previous by thread: Re: Problems with firstResponder
  • Next by thread: setTitleWithMnemonic
  • Index(es):
    • Date
    • Thread