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

Re: Getting NSTextField from NSWindow firstResponder


  • Subject: Re: Getting NSTextField from NSWindow firstResponder
  • From: Stéphane Sudre <email@hidden>
  • Date: Sat, 29 Nov 2003 22:59:15 +0100

Possible solution:

Set the NSDocument subclass instance to be the delegate of the Window.

Add a data member to your subclass:

id currentObjectForFieldEditor_:

And implement in your subclass:

- (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)anObject
{
currentObjectForFieldEditor_= anObject;

return nil;
}

you now have the NSTextField being edited.

On samedi, novembre 29, 2003, at 10:14 PM, Ed Watkeys wrote:

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.
_______________________________________________
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.

References: 
 >Getting NSTextField from NSWindow firstResponder (From: Ed Watkeys <email@hidden>)

  • Prev by Date: do periodic NSTask yet allow sleep?
  • Next by Date: ASKNibConnector class not found
  • Previous by thread: Getting NSTextField from NSWindow firstResponder
  • Next by thread: Re: Getting NSTextField from NSWindow firstResponder
  • Index(es):
    • Date
    • Thread