• 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: Resorting normal field editor behaviour
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Resorting normal field editor behaviour


  • Subject: Re: Resorting normal field editor behaviour
  • From: "K. Darcy Otto" <email@hidden>
  • Date: Thu, 3 Apr 2008 16:09:57 -0700

Thank you very much; this is exactly the solution. Just for others who might have this problem, here is how i solved it:

1. Set up a NSText variable globally: NSText *fieldEd
2. Implement controlTextDidBeginEditing: as below:

-(void)controlTextDidBeginEditing:(NSNotification *)notification
{
    fieldEd = [[notification userInfo] objectForKey:@"NSFieldEditor"];
}

3. Implement the delegates you need (in my case controlTextDidChange: in order to modify the text as the user enters it).

There is no need to use windowWillReturnFieldEditor, which is what I was trying to do before.

On 3-Apr-08, at 9:02 AM, Nate Weaver wrote:

I think what you probably want is to not use a custom field editor, but instead set your controller to the NSTableView's delegate (which it probably already is) and use the @"NSFieldEditor" key of the notification's userInfo dictionary to access the field editor. (Hopefully NSTableView isn't special and still calls controlTextDidChange: on its delegate; I can't remember).

If what you're doing is validating the field's contents, you might want to look at making an NSFormatter subclass and assigning it to your data cells.

Presumably the normal behavior disappears because the control is usually the delegate of the field editor, and it intercepts tab/ return/etc. and does its own thing with them (IIRC).

On Apr 2, 2008, at 11:54 PM, K.Darcy Otto wrote:
I need to intercept changes in my NSTableView's field editor, and I am able to do this successfully implementing controlTextDidChange: in my controller. I do this by having my controller create a field editor (fieldEd, an NSTextView) and setting the delegate of that field editor to my controller. Then, I use windowWillReturnFieldEditor: to return fieldEd, so that when the NSTableView wants to do some editing, it gets pointed to the right object. So far, so good.

The problem is that I lose some normal field-editor behaviour. In particular, the field editor does not give up control when I press <enter>, <tab> or <backtab>, but instead enters these characters directly into the field (there may be some other issues as well; arrows work as expected). How do I restore normal behaviour, and (for the interest's sake) why has normal behaviour disappeared? Thanks.

_______________________________________________

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


References: 
 >Resorting normal field editor behaviour (From: K.Darcy Otto <email@hidden>)
 >Re: Resorting normal field editor behaviour (From: Nate Weaver <email@hidden>)

  • Prev by Date: Re: Need for a creator code?
  • Next by Date: Re: duplicate symbol error
  • Previous by thread: Re: Resorting normal field editor behaviour
  • Next by thread: 1 pixel bordered CALayer renders improperly
  • Index(es):
    • Date
    • Thread