Instance Method

validateProposedFirstResponder:forEvent:

Allows controls to determine when they should become first responder.

Declaration

- (BOOL)validateProposedFirstResponder:(NSResponder *)responder forEvent:(NSEvent *)event;

Parameters

responder

The first responder.

event

The event to validate. May be nil if there is no applicable event.

Return Value

YES if the control should become first responder, otherwise NO.

Discussion

Some controls, such as NSTextField, should only become first responder when the enclosing NSTableView/NSBrowser indicates that the view can begin editing. It is up to the particular control that wants to be validated to call this method in its mouseDown: method (or perhaps at another time) to determine if it should attempt to become the first responder or not.

The NSTableView, NSOutlineView, and NSBrowser classes implement this to allow first responder status only if the responder is a view in a selected row. It also delays the first responder assignment if a doubleAction may be invoked.

The default implementation returns YES when there is no nextResponder set, otherwise, it is forwarded up the responder chain.

See Also

Changing the First Responder

acceptsFirstResponder

A Boolean value that indicates whether the responder accepts first responder status.

- becomeFirstResponder

Notifies the receiver that it’s about to become first responder in its NSWindow.

- resignFirstResponder

Notifies the receiver that it’s been asked to relinquish its status as first responder in its window.