Stairways Software Icon

Stairways Software

Excellence In Software For Over Ten Years – Only with a Mac

Field Editor Issues

The editing a text field, cocoa uses a shared field editor, which switches text fields as the user tabs around the window. This technique is designed to save resources, and it is unlikely it is needed on modern hardware, but for now we're stuck with it.

The field editor brings up a number of issues, here are some helpful tips for handling them.

There is usually a single shared editor for a window, but the window delegate can provide a custom field editor or different editors for different text fields. To return a custom field editor, use the window delegate method windowWillReturnFieldEditor:toObject:

To test whether a text field is being edited, check [field currentEditor], which returns the field editor or nil if the text field is not being edited.

To get from the field editor to the current text field, you use (NSTextField*)[fieldEditor delegate].

The field editor is added as a subview of the text field. So to determine if a text field is the current first responder, use [textField.window.firstResponder isDescendantOf:textField]. Note that you need to check that textField.window.firstResponder isKindOfClass:[NSView class] first.

Posted Friday, May 6, 2011. Permalink. Post a Comment.


Post Comment

Name: (optional)
URL: (optional)
Email: (optional, not published)
CAPTCHA: six one one four (required)
  To prove you are human, please enter the number as digits (ie, 1-9).
  You can use some HTML tags such as <b>, <i>, and <a href="">.
We reserve the right to remove any offensive or inappropriate comments.
Due to spam issues, comments are initially invisible until we review them,
you can see them (background red) and we can see them, but no one else.

Comment Preview

None yet.

Buy Now

User Database