views:

28

answers:

1

I' using

- (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)anObject 

to provide my own field editor so i can display a custom context menu. This works but when inside the "menuForEvent:" method of my field editor, how can i find to which NSTextField it is attached?

EDIT: okay i found that i get it via inside the TextView via

[[[[self window] firstResponder] nextResponder] nextResponder]

The question is - is this a good solution or a hack. I have to skip an internal responder of class _NSKeyboardFocusClipView so i scared that this might not work on future Cocoa versions.

A: 

I wouldn't want to rely on the responder chain for that, seems rather fragile.

I'd try to add a property to my field editor class and set that to anObject in the windowWillReturnFieldEditor:toObject: delegate method.

Sven
I tried this before but it doesn't work for some nknown reasons. BTW putting a printf in this method made me sick to see how many times it is called.
Lothar