• 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: makeFirstResponder NOT working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: makeFirstResponder NOT working


  • Subject: Re: makeFirstResponder NOT working
  • From: Matt Neuburg <email@hidden>
  • Date: Wed, 29 Sep 2004 16:33:52 -0700

On or about 9/29/04 3:14 PM, thus spake "email@hidden"
<email@hidden>:

> The only thing that may be relevant is that I am using
> [NSAPP runModalForWindow: myWindow]
> to load the Window. Do you think it could the reason for the problem?

Well, obviously! In that case you'd have to say this:

[[sender window]
  performSelector:@selector(makeFirstResponder:)
  withObject:textField1
  afterDelay:0
  inModes:[NSArray arrayWithObject:NSModalPanelRunLoopMode]];

Now, you may have a further problem. In my experience in this situation
typing Return in the field may not even trigger the default button. So its
action method isn't even being called. I have discussed the matter here:

<http://www.cocoabuilder.com/archive/message/2004/7/20/112248>

and here:

<http://www.cocoabuilder.com/archive/message/2002/9/16/70936>

The idea is you will have to push the button yourself, e.g.:

[[theWindow defaultButtonCell] performClick: self];

Depending on how things are set up, you could do this in the field's action
method, or you could do it in the delegate's
control:textView:doCommandBySelector:, testing for insertNewLine:. Or
elsewhere.

m.

> Citando Matt Neuburg <email@hidden>:
>
>> On or about 9/29/04 1:49 PM, thus spake "email@hidden"
>> <email@hidden>:
>>
>>> Tried it, but it did not solve the problem
>>
>> Then something else is going on that you are not telling, since it works
>> fine here. I made a test project before sending you my reply. m.
>>
>>> Citando Matt Neuburg <email@hidden>:
>>>
>>>> On Wed, 29 Sep 2004 14:31:02 -0300, email@hidden said:
>>>>> I have a Window and in it I have 3 NSTextFields and 2 NSButtons. My OK
>>>>> Button has \r for its key equivalent.
>>>>>
>>>>> Well, I would like to make the first NSTextField the First Responder after
>>>>> I click the OK Button or press the RETURN key. The code that will be
>>>>> executed when I either click the OK button or type the RETURN key has the
>>>>> following statement:
>>>>>
>>>>> [[self window] makeFirstReponder: textField1];
>>>>>
>>>>> The thing is when I click the OK button it all works just fine, BUT when I
>>>>> press the RETURN key, the statemente above is  not respected by COCOA and
>>>>> the First Responder is the last NSTextField edited and NOT the First
>>>>> NSTextField.
>>>>>
>>>>> How can I tell COCOA that I want the First Responder to be the first
>>>>> NSTextField either when the user clicks the OK button or when the user
>>>>> presses the RETURN key, which is the OK button's key equivalent?
>>>>
>>>> Use delayed performance. There need not be any real delay. So:
>>>>
>>>> [[sender window]
>>>>   performSelector:@selector(makeFirstResponder:)
>>>>   withObject:textField1
>>>>   afterDelay:0];
>>

--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide! NOW SHIPPING...! (Finally.)
http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: makeFirstResponder NOT working
      • From: email@hidden
References: 
 >Re: makeFirstResponder NOT working (From: email@hidden)

  • Prev by Date: Re: makeFirstResponder NOT working
  • Next by Date: Re: NSDocument and Saving File Packages
  • Previous by thread: Re: makeFirstResponder NOT working
  • Next by thread: Re: makeFirstResponder NOT working
  • Index(es):
    • Date
    • Thread