Getting NSTextField from NSWindow firstResponder
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.