• 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
Getting NSTextField from NSWindow firstResponder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting NSTextField from NSWindow firstResponder


  • Subject: Getting NSTextField from NSWindow firstResponder
  • From: Ed Watkeys <email@hidden>
  • Date: Sat, 29 Nov 2003 16:14:28 -0500

Hi,

Calling firstResponder on an NSWindow returns an NSTextView when an NSTextField has focus. This is because the NSTextView is the field editor for the NSWindow, and it is taking care of text editing duties for all NSTextFields in the NSWindow.

I need to find out what NSTextField the NSTextView is working on behalf of. I'm doing something similar to the following in my subclass of NSDocument's dataRepresentationOfType: message:

r = [window getFirstResponder];
[window setFirstResponder:nil];

// The active text field ended editing, so it sent a message to its
// target (me), and I stored it away in my data model.

// Create an NSData object from my data model.

[window makeFirstResponder:r];

To restate and clarify: since r refers to the shared NSTextView, making it the first responder is doing nothing constructive. I need a way to get from the NSTextView to the NSTextField, so I can put focus back on the UI object that had focus before I called setFirstResponder:. Any help would be appreciated.

Regards,
Ed
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Getting NSTextField from NSWindow firstResponder
      • From: James Spencer <email@hidden>
    • Re: Getting NSTextField from NSWindow firstResponder
      • From: Stéphane Sudre <email@hidden>
  • Prev by Date: Re: Comparing two images
  • Next by Date: do periodic NSTask yet allow sleep?
  • Previous by thread: Problems with NSConnection over NSSocketPort
  • Next by thread: Re: Getting NSTextField from NSWindow firstResponder
  • Index(es):
    • Date
    • Thread