• 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: [SOLVED] Re: How to override [NSTextField paste:]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [SOLVED] Re: How to override [NSTextField paste:]


  • Subject: Re: [SOLVED] Re: How to override [NSTextField paste:]
  • From: Kyle Sluder <email@hidden>
  • Date: Fri, 15 Jun 2012 22:43:07 -0700

On Jun 15, 2012, at 4:23 PM, Graham Cox <email@hidden> wrote:

>
> On 16/06/2012, at 4:06 AM, Kyle Sluder wrote:
>
>> Your best bet is probably to retarget the Paste menu item to use a different selector that is picked up by your window controller.
>
> Thanks Kyle,
>
> Unfortunately the standard paste: selector is used extensively elsewhere in my app, so this simple solution would not be so simple. This is an otherwise very self-contained modal dialog that doesn't have much to do.

The good thing about this solution is that it does fall back to sending -paste:. But you are right; it does seem a bit heavy-handed for your localized need.

>
> I solved it as follows:
>
>
> My window controller, which is the window's delegate, implements -windowWillReturnFieldEditor:forObject:. I return a subclass of NSTextView which overrides -paste: and adds a property, -pasteDelegate: which I set to be the window controller. (I believe the FE's nextResponder is usually also the windowController, but I wasn't entirely sure I could rely on that, so I just added an extra property to hook it up). Then I just punt -paste to the -pasteDelegate (and also -validateMenuItem for that action).

Cool. In order to avoid a retain cycle or a dangling pointer, instead of using a pasteDelegate (since there's no clear place to nil the property out) I would probably just use [[self window] windowController].

--Kyle Sluder

_______________________________________________

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: 
 >How to override [NSTextField paste:] (From: Graham Cox <email@hidden>)
 >Re: How to override [NSTextField paste:] (From: Kyle Sluder <email@hidden>)
 >[SOLVED] Re: How to override [NSTextField paste:] (From: Graham Cox <email@hidden>)

  • Prev by Date: [SOLVED] Re: How to override [NSTextField paste:]
  • Next by Date: Re: updates for retina
  • Previous by thread: [SOLVED] Re: How to override [NSTextField paste:]
  • Next by thread: Core Image
  • Index(es):
    • Date
    • Thread