Per protocol ref, windowWillReturnFieldEditor should be called for any text-displaying object when it needs a field editor. Indeed, my window delegate receives a call to this meth开发者_开发问答od for textfields, buttons, comboboxes, etc. — but never for textviews.
Is this normal? Does NSTextView carry its own field editor and never request one? Or what am I missing?
- (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)anObject {
if ([anObject isKindOfClass:[NSTextView class]])
printf("\nwinWillRtnFldEdtor called for some textview."); // never happens
}
Drats. Looking at memory addresses of the field editors, it is apparent that every textview does indeed have its own distinct field editor (unlike the textfields, which share a common field editor), and so textviews never request a field editor and never call this method.
Which is unfortunate, since I need special routines to set up multiple distinct textviews just before they become active. (It was easier to do this with textfields.) The best workaround I can think of is to add a tag-like property to the textviews.
精彩评论