makeFirstResponder:
Attempts to make a given responder the first responder for the window.
- (BOOL)makeFirstResponder:(NSResponder *)responder
Parameters
responder
The responder to set as the window’s first responder. nil makes the window its first responder.
Return Value
YES when the operation is successful; otherwise, NO.
Discussion
If responder isn’t already the first responder, this method first sends a resignFirstResponder message to the object that is the first responder. If that object refuses to resign, it remains the first responder, and this method immediately returns NO. If the current first responder resigns, this method sends a becomeFirstResponder message to responder. If responder does not accept first responder status, the NSWindow object becomes first responder; in this case, the method returns YES even if responder refuses first responder status.
If responder is nil, this method still sends resignFirstResponder to the current first responder. If the current first responder refuses to resign, it remains the first responder and this method immediately returns NO. If the current first responder returns YES from resignFirstResponder, the window is made its own first responder and this method returns YES.
The Application Kit framework uses this method to alter the first responder in response to mouse-down events; you can also use it to explicitly set the first responder from within your program. The responder object is typically an NSView object in the window’s view hierarchy. If this method is called explicitly, first send acceptsFirstResponder to responder, and do not call makeFirstResponder: if acceptsFirstResponder returns NO.
Use setInitialFirstResponder: to the set the first responder to be used when the window is brought onscreen for the first time.