> On 2014/08/17, at 13:03, Ken Thomases <k...@codeweavers.com> wrote:
>
>
> I recommend that you do a variant of the technique outlined in Technical Q&A
> QA1454: How to make NSTextField accept tab, return and enter keys.
> https://developer.apple.com/library/mac/qa/qa1454/_index.html
>
> The general mechanism is to implement the control delegate method
> -control:textView:doCommandBySelector: and alter the response to the
> "insertNewline:" selector.
>
> You're not interested in inserting the newline into the text, but you can
> adjust the response to the return key in other ways. If you return YES, you
> stop any further processing of the selector. That allows you to have
> complete control over the response. As to what you do before returning YES,
> I think it should be sufficient to make another view (or the window itself)
> the window's first responder using -[NSWindow makeFirstResponder:].
>
> Probably, making the table view itself the first responder makes the most
> sense, although perhaps there's an intervening ancestor view between the text
> field and the table view that would make more sense in your case. Or perhaps
> you could just delegate the logic to -[NSWindow selectNextKeyView:], to make
> it as though the user had hit Tab instead of return. (I would be amused by
> the irony of subverting the Tech Q&A by translating an invocation of
> -insertNewline: into an invocation of -insertTab:, too.)
>
> Regards,
> Ken
Remember the field editor defaults to a shared instance of NSTextView basically
that is owned by the window.
You can always create a unique one and assign it to your text fields.
This is a bit more heavy weight than the simpler delegate approach but also
gives complete control while allowing you to use the default field editor for
text fields outside your table.
Though the delegate approach should give you just the same ability if you check
where the text field belongs in some way.
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com