On Jun 15, 2012, at 4:23 PM, Graham Cox <graham....@bigpond.com> 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 (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