• 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: Stop edit session with a NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stop edit session with a NSTextField


  • Subject: Re: Stop edit session with a NSTextField
  • From: Eric Gorr <email@hidden>
  • Date: Tue, 24 Feb 2009 18:08:10 -0500


On Feb 24, 2009, at 5:47 PM, Eric Gorr wrote:


On Feb 23, 2009, at 11:35 AM, Eric Gorr wrote:


On Feb 23, 2009, at 11:01 AM, Patrick Mau wrote:


On 23.02.2009, at 16:50, Eric Gorr wrote:


I am not sure I understand this.

Are you are saying is that you looked for the NSTextView being used as the field editor for the NSTextField and then removed the NSTextView from it's superview?

I tried this:

id fieldEditor = [[aNotification userInfo] objectForKey:@"NSFieldEditor"];
[fieldEditor removeFromSuperview];


Unfortunately, it didn't work.

Yes. The superview of the fieldeditor is some clipping view (I forgot the class).

ah, ok. Makes more sense now.

In any case, the solution to my problem turned out to be not so bad. I simply did the following:

[[[self view] window] makeFirstResponder:[self view]];

Basically, told the window to make someone else the first responder. This seemed to work.

I do find it odd that I could not tell the field editor to resign as first responder.

Unfortunately, this solution isn't complete.

If one presses the tab key, I see my controlTextDidEndEditing getting called which does successfully set the first responder elsewhere, but the field editor steals first responder status back - something which you probably already knew.

I will try your solution and see if I can get it to work.

Unfortunately, it does not work either.

If anyone has any further ideas on how to correctly end an editing session of a NSTextField, I am interested.

To summarize the proposed and failed solutions:



*** [[[self view] window] endEditingFor:nil];

Pressing return or pressing the tab key will not end the editing session



*** [[[self view] window] makeFirstResponder:[self view]];

Pressing return will allow the editing session to end, but pressing the tab key will not



*** NSTextView *fieldEditor = [[aNotification userInfo] objectForKey:@"NSFieldEditor"];
NSView *v = fieldEditor;
while ( v && ( [v superview] != [aNotification object] ) )
v = [v superview];
[v removeFromSuperview];


Pressing return or pressing the tab key will not end the editing session


The editing session was started with:

[textField selectText:nil];
NSTextView *currentEditor = (NSTextView*)[textField currentEditor];
NSPoint windowLocation = [theEvent locationInWindow];
NSPoint screenLocation = [[self window] convertBaseToScreen:windowLocation];
NSUInteger characterIndex = [currentEditor characterIndexForPoint:screenLocation];
[currentEditor setSelectedRange:NSMakeRange( characterIndex + 1, 0 )];


NOTE: normally, the NSTextField is not editable and is drawn as a static text string


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Stop edit session with a NSTextField
      • From: Andy Lee <email@hidden>
    • Re: Stop edit session with a NSTextField
      • From: Patrick Mau <email@hidden>
References: 
 >Stop edit session with a NSTextField (From: Eric Gorr <email@hidden>)
 >Re: Stop edit session with a NSTextField (From: Patrick Mau <email@hidden>)
 >Re: Stop edit session with a NSTextField (From: Eric Gorr <email@hidden>)
 >Re: Stop edit session with a NSTextField (From: Patrick Mau <email@hidden>)
 >Re: Stop edit session with a NSTextField (From: Eric Gorr <email@hidden>)
 >Re: Stop edit session with a NSTextField (From: Eric Gorr <email@hidden>)

  • Prev by Date: Help with sheets, NSArrayController & NSTableView (all working together) ...
  • Next by Date: Re: Strange NSManagedObjectContextObjectsDidChangeNotification behavior
  • Previous by thread: Re: Stop edit session with a NSTextField
  • Next by thread: Re: Stop edit session with a NSTextField
  • Index(es):
    • Date
    • Thread